diff --git a/test/app/routes/api/blog/[slug].js b/test/app/routes/api/blog/[slug].js index ea975b8..0813e7f 100644 --- a/test/app/routes/api/blog/[slug].js +++ b/test/app/routes/api/blog/[slug].js @@ -13,7 +13,7 @@ export function get(req, res, next) { if (slug in lookup) { res.set({ 'Content-Type': 'application/json', - 'Cache-Control': `max-age=${30 * 60 * 1e3}` // cache for 30 minutes + 'Cache-Control': `no-cache` }); res.end(lookup[slug]); diff --git a/test/common/test.js b/test/common/test.js index c8a0cfa..48a8ccd 100644 --- a/test/common/test.js +++ b/test/common/test.js @@ -208,6 +208,31 @@ function run(env) { assert.ok(scrollY > 0, scrollY); }); + + it('reuses prefetch promise', async () => { + await nightmare + .goto(`${base}/blog`) + .wait(() => window.READY) + .wait(200); + + const mouseover_requests = (await capture(async () => { + await nightmare + .mouseover('[href="/blog/what-is-sapper"]') + .wait(200); + })).map(r => r.url); + + assert.deepEqual(mouseover_requests, [ + '/api/blog/what-is-sapper' + ]); + + const click_requests = (await capture(async () => { + await nightmare + .click('[href="/blog/what-is-sapper"]') + .wait(200); + })).map(r => r.url); + + assert.deepEqual(click_requests, []); + }); }); describe('headers', () => {