({ dev })
| 28 | const buildIdPath = join(appDir, '.next/BUILD_ID') |
| 29 | |
| 30 | function runTests({ dev }) { |
| 31 | if (!dev) { |
| 32 | it('should have correct cache entries on prefetch', async () => { |
| 33 | const browser = await webdriver(appPort, '/') |
| 34 | await browser.waitForCondition('!!window.next.router.isReady') |
| 35 | |
| 36 | const getCacheKeys = async () => { |
| 37 | return (await browser.eval('Object.keys(window.next.router.sdc)')) |
| 38 | .map((key) => { |
| 39 | // strip http://localhost:PORT |
| 40 | // and then strip buildId prefix |
| 41 | return key |
| 42 | .substring(key.indexOf('/_next')) |
| 43 | .replace(/\/_next\/data\/(.*?)\//, '/_next/data/BUILD_ID/') |
| 44 | }) |
| 45 | .sort() |
| 46 | } |
| 47 | |
| 48 | const cacheKeys = await getCacheKeys() |
| 49 | expect(cacheKeys).toEqual( |
| 50 | process.env.__MIDDLEWARE_TEST |
| 51 | ? [ |
| 52 | '/_next/data/BUILD_ID/[name].json?another=value&name=%5Bname%5D', |
| 53 | '/_next/data/BUILD_ID/added-later/first.json?name=added-later&comment=first', |
| 54 | '/_next/data/BUILD_ID/blog/321/comment/123.json?name=321&id=123', |
| 55 | '/_next/data/BUILD_ID/d/dynamic-1.json?id=dynamic-1', |
| 56 | '/_next/data/BUILD_ID/on-mount/test-w-hash.json?post=test-w-hash', |
| 57 | '/_next/data/BUILD_ID/p1/p2/all-ssg/hello.json?rest=hello', |
| 58 | '/_next/data/BUILD_ID/p1/p2/all-ssg/hello1/hello2.json?rest=hello1&rest=hello2', |
| 59 | '/_next/data/BUILD_ID/p1/p2/all-ssr/:42.json?rest=%3A42', |
| 60 | '/_next/data/BUILD_ID/p1/p2/all-ssr/hello.json?rest=hello', |
| 61 | '/_next/data/BUILD_ID/p1/p2/all-ssr/hello1%2F/he%2Fllo2.json?rest=hello1%2F&rest=he%2Fllo2', |
| 62 | '/_next/data/BUILD_ID/p1/p2/all-ssr/hello1/hello2.json?rest=hello1&rest=hello2', |
| 63 | '/_next/data/BUILD_ID/p1/p2/nested-all-ssg/hello.json?rest=hello', |
| 64 | '/_next/data/BUILD_ID/p1/p2/nested-all-ssg/hello1/hello2.json?rest=hello1&rest=hello2', |
| 65 | '/_next/data/BUILD_ID/post-1.json?fromHome=true&name=post-1', |
| 66 | '/_next/data/BUILD_ID/post-1.json?hidden=value&name=post-1', |
| 67 | '/_next/data/BUILD_ID/post-1.json?name=post-1', |
| 68 | '/_next/data/BUILD_ID/post-1.json?name=post-1&another=value', |
| 69 | '/_next/data/BUILD_ID/post-1/comment-1.json?name=post-1&comment=comment-1', |
| 70 | '/_next/data/BUILD_ID/post-1/comments.json?name=post-1', |
| 71 | ] |
| 72 | : [ |
| 73 | '/_next/data/BUILD_ID/p1/p2/all-ssg/hello.json?rest=hello', |
| 74 | '/_next/data/BUILD_ID/p1/p2/all-ssg/hello1/hello2.json?rest=hello1&rest=hello2', |
| 75 | '/_next/data/BUILD_ID/p1/p2/nested-all-ssg/hello.json?rest=hello', |
| 76 | '/_next/data/BUILD_ID/p1/p2/nested-all-ssg/hello1/hello2.json?rest=hello1&rest=hello2', |
| 77 | ] |
| 78 | ) |
| 79 | |
| 80 | // ensure no new cache entries after navigation |
| 81 | const links = [ |
| 82 | { |
| 83 | linkSelector: '#ssg-catch-all-single', |
| 84 | waitForSelector: '#all-ssg-content', |
| 85 | }, |
| 86 | { |
| 87 | linkSelector: '#ssg-catch-all-single-interpolated', |
no test coverage detected