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

Function runTests

test/development/jsconfig-path-reloading/index.test.ts:20–183  ·  view source on GitHub ↗
({ addAfterStart }: { addAfterStart?: boolean })

Source from the content-addressed store, hash-verified

18 const indexPage = 'pages/index.js'
19
20 function runTests({ addAfterStart }: { addAfterStart?: boolean }) {
21 beforeAll(async () => {
22 let tsConfigContent = await fs.readFile(
23 join(__dirname, 'app/jsconfig.json'),
24 'utf8'
25 )
26
27 next = await createNext({
28 files: {
29 components: new FileRef(join(__dirname, 'app/components')),
30 pages: new FileRef(join(__dirname, 'app/pages')),
31 lib: new FileRef(join(__dirname, 'app/lib')),
32 ...(addAfterStart
33 ? {}
34 : {
35 [tsConfigFile]: tsConfigContent,
36 }),
37 },
38 dependencies: {
39 typescript: 'latest',
40 '@types/react': 'latest',
41 '@types/node': 'latest',
42 },
43 })
44
45 if (addAfterStart) {
46 await next.patchFile(tsConfigFile, tsConfigContent)
47 }
48 })
49 afterAll(() => next.destroy())
50
51 it('should load with initial paths config correctly', async () => {
52 const html = await renderViaHTTP(next.url, '/')
53 const $ = cheerio.load(html)
54 expect(html).toContain('first button')
55 expect(html).toContain('second button')
56 expect($('#first-data').text()).toContain(
57 JSON.stringify({
58 hello: 'world',
59 })
60 )
61 })
62
63 it('should recover from module not found when paths is updated', async () => {
64 const indexContent = await next.readFile(indexPage)
65 const tsconfigContent = await next.readFile(tsConfigFile)
66 const parsedTsConfig = JSON.parse(tsconfigContent)
67
68 const browser = await webdriver(next.url, '/')
69
70 try {
71 const html = await browser.eval('document.documentElement.innerHTML')
72 expect(html).toContain('first button')
73 expect(html).toContain('second button')
74 expect(html).toContain('id="first-data"')
75 expect(html).not.toContain('id="second-data"')
76
77 await next.patchFile(

Callers 1

index.test.tsFile · 0.70

Calls 15

joinFunction · 0.90
createNextFunction · 0.90
renderViaHTTPFunction · 0.90
waitForRedboxFunction · 0.90
getRedboxSourceFunction · 0.90
waitForNoRedboxFunction · 0.90
checkFunction · 0.90
webdriverFunction · 0.85
evalMethod · 0.80
includesMethod · 0.80
loadMethod · 0.65
textMethod · 0.65

Tested by

no test coverage detected