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

Function runTests

test/integration/prerender-fallback-encoding/test/index.test.ts:57–315  ·  view source on GitHub ↗
(isDev: boolean)

Source from the content-addressed store, hash-verified

55const pagesDir = join(appDir, '.next/server/pages')
56
57function runTests(isDev: boolean) {
58 if (!isDev) {
59 it('should output paths correctly', async () => {
60 for (const path of prerenderedPaths) {
61 for (const mode of modePaths) {
62 console.log('checking output', { path, mode })
63 expect(fs.existsSync(join(pagesDir, mode, path + '.html'))).toBe(true)
64 expect(fs.existsSync(join(pagesDir, mode, path + '.json'))).toBe(true)
65 }
66 }
67 })
68
69 it('should handle non-prerendered paths correctly', async () => {
70 const prerenderedPaths = [
71 '%2Fanother-post%2F',
72 '+another-post+',
73 '%3Fanother-post%3F',
74 '&another-post&',
75 '商業日語商業日語',
76 ]
77
78 const urlPaths = [
79 '%2Fanother-post%2F',
80 '%2Banother-post%2B',
81 '%3Fanother-post%3F',
82 '%26another-post%26',
83 encodeURIComponent('商業日語商業日語'),
84 ]
85
86 for (const mode of modePaths) {
87 for (let i = 0; i < urlPaths.length; i++) {
88 const testSlug = urlPaths[i]
89 const path = prerenderedPaths[i]
90
91 const res = await fetchViaHTTP(
92 appPort,
93 `/_next/data/${buildId}/${mode}/${testSlug}.json`
94 )
95
96 if (mode === 'fallback-false') {
97 expect(res.status).toBe(404)
98 } else {
99 expect(res.status).toBe(200)
100
101 const { pageProps: props } = await res.json()
102
103 expect(props.params).toEqual({
104 slug: decodeURIComponent(testSlug),
105 })
106
107 if (!isDev) {
108 // we don't block on writing incremental data to the
109 // disk so use check
110 await check(
111 () => fs.existsSync(join(pagesDir, mode, path + '.html')),
112 true
113 )
114 await check(

Callers 1

index.test.tsFile · 0.70

Calls 15

joinFunction · 0.90
fetchViaHTTPFunction · 0.90
checkFunction · 0.90
encodeURIComponentFunction · 0.85
webdriverFunction · 0.85
elementByCssMethod · 0.80
evalMethod · 0.80
textMethod · 0.65
loadMethod · 0.65
itFunction · 0.50
expectFunction · 0.50
$Function · 0.50

Tested by

no test coverage detected