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

Function runTests

test/integration/i18n-support-catchall/test/index.test.ts:24–217  ·  view source on GitHub ↗
(isDev: boolean)

Source from the content-addressed store, hash-verified

22const locales = ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en']
23
24function runTests(isDev: boolean) {
25 if (!isDev) {
26 it('should output prerendered index routes correctly', async () => {
27 expect(fs.existsSync(join(buildPagesDir, 'pages/en-US.html'))).toBe(true)
28 expect(fs.existsSync(join(buildPagesDir, 'pages/en-US.json'))).toBe(true)
29 expect(fs.existsSync(join(buildPagesDir, 'pages/fr.html'))).toBe(true)
30 expect(fs.existsSync(join(buildPagesDir, 'pages/fr.json'))).toBe(true)
31 })
32 }
33
34 it('should load the index route correctly SSR', async () => {
35 const res = await fetchViaHTTP(appPort, '/', undefined, {
36 redirect: 'manual',
37 })
38 expect(res.status).toBe(200)
39
40 const html = await res.text()
41 const $ = cheerio.load(html)
42
43 expect($('#router-locale').text()).toBe('en-US')
44 expect($('#router-default-locale').text()).toBe('en-US')
45 expect($('#router-pathname').text()).toBe('/[[...slug]]')
46 expect($('#router-as-path').text()).toBe('/')
47 expect(JSON.parse($('#props').text())).toEqual({
48 params: {},
49 locale: 'en-US',
50 locales,
51 defaultLocale: 'en-US',
52 })
53 expect(JSON.parse($('#router-locales').text())).toEqual(locales)
54 })
55
56 it('should load the index route correctly CSR', async () => {
57 const browser = await webdriver(appPort, '/')
58
59 expect(await browser.elementByCss('#router-locale').text()).toBe('en-US')
60 expect(await browser.elementByCss('#router-default-locale').text()).toBe(
61 'en-US'
62 )
63 expect(await browser.elementByCss('#router-pathname').text()).toBe(
64 '/[[...slug]]'
65 )
66 expect(await browser.elementByCss('#router-as-path').text()).toBe('/')
67 expect(
68 JSON.parse(await browser.elementByCss('#router-locales').text())
69 ).toEqual(locales)
70 expect(JSON.parse(await browser.elementByCss('#props').text())).toEqual({
71 params: {},
72 locale: 'en-US',
73 locales,
74 defaultLocale: 'en-US',
75 })
76 })
77
78 it('should navigate to other locale index and back', async () => {
79 const browser = await webdriver(appPort, '/')
80
81 await browser.elementByCss('#to-locale-index').click()

Callers 1

index.test.tsFile · 0.70

Calls 15

joinFunction · 0.90
fetchViaHTTPFunction · 0.90
checkFunction · 0.90
webdriverFunction · 0.85
elementByCssMethod · 0.80
clickMethod · 0.80
evalMethod · 0.80
textMethod · 0.65
loadMethod · 0.65
backMethod · 0.65
replaceMethod · 0.65
itFunction · 0.50

Tested by

no test coverage detected