MCPcopy
hub / github.com/vercel/next.js / runTests

Function runTests

test/integration/dynamic-routing/test/index.test.ts:30–1585  ·  view source on GitHub ↗
({ dev })

Source from the content-addressed store, hash-verified

28const buildIdPath = join(appDir, '.next/BUILD_ID')
29
30function 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',

Callers 1

index.test.tsFile · 0.70

Calls 15

checkFunction · 0.90
fetchViaHTTPFunction · 0.90
retryFunction · 0.90
renderViaHTTPFunction · 0.90
waitForFunction · 0.90
joinFunction · 0.90
waitForRedboxFunction · 0.90
getRedboxHeaderFunction · 0.90
normalizeRegExFunction · 0.90
normalizeManifestFunction · 0.90
webdriverFunction · 0.85
getCacheKeysFunction · 0.85

Tested by

no test coverage detected