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

Function runTests

test/integration/fallback-false-rewrite/test/index.test.ts:20–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18let app
19
20const runTests = () => {
21 it('should rewrite correctly for path at same level as fallback: false SSR', async () => {
22 const res = await fetchViaHTTP(appPort, '/hello', undefined, {
23 redirect: 'manual',
24 })
25 expect(res.status).toBe(200)
26
27 const html = await res.text()
28 const $ = cheerio.load(html)
29
30 expect($('#another').text()).toBe('another')
31 expect(JSON.parse($('#query').text())).toEqual({
32 path: ['hello'],
33 })
34 })
35
36 it('should rewrite correctly for path above fallback: false SSR', async () => {
37 const res = await fetchViaHTTP(appPort, '/hello/world', undefined, {
38 redirect: 'manual',
39 })
40 expect(res.status).toBe(200)
41
42 const html = await res.text()
43 const $ = cheerio.load(html)
44
45 expect($('#another').text()).toBe('another')
46 expect(JSON.parse($('#query').text())).toEqual({
47 path: ['hello', 'world'],
48 })
49 })
50
51 it('should rewrite correctly for path at same level as fallback: false client', async () => {
52 const browser = await webdriver(appPort, '/hello')
53
54 expect(await browser.elementByCss('#another').text()).toBe('another')
55 expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({
56 path: ['hello'],
57 })
58 })
59
60 it('should rewrite correctly for path above fallback: false client', async () => {
61 const browser = await webdriver(appPort, '/hello/world')
62
63 expect(await browser.elementByCss('#another').text()).toBe('another')
64 expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({
65 path: ['hello', 'world'],
66 })
67 })
68
69 it('should not rewrite for path from fallback: false SSR', async () => {
70 const res = await fetchViaHTTP(appPort, '/first', undefined, {
71 redirect: 'manual',
72 })
73 expect(res.status).toBe(200)
74
75 const html = await res.text()
76 const $ = cheerio.load(html)
77

Callers 1

index.test.tsFile · 0.70

Calls 9

fetchViaHTTPFunction · 0.90
webdriverFunction · 0.85
elementByCssMethod · 0.80
textMethod · 0.65
loadMethod · 0.65
itFunction · 0.50
expectFunction · 0.50
$Function · 0.50
parseMethod · 0.45

Tested by

no test coverage detected