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

Function runTests

test/integration/repeated-slashes/test/index.test.ts:27–411  ·  view source on GitHub ↗
({ isDev = false, isExport = false, isPages404 = false })

Source from the content-addressed store, hash-verified

25let app
26
27function runTests({ isDev = false, isExport = false, isPages404 = false }) {
28 let notFoundContent = 'custom error'
29 // let badRequestContent = 'custom error'
30
31 if (isPages404) {
32 // badRequestContent = 'Bad Request'
33 notFoundContent = 'custom 404'
34 }
35 if (isExport && isPages404) {
36 notFoundContent = 'custom 404'
37 // badRequestContent = 'custom 404'
38 }
39
40 const didNotReload = async (browser) => {
41 for (let i = 0; i < 4; i++) {
42 await waitFor(500)
43
44 const result = await browser.eval('window.errorLoad')
45
46 if (result !== true) {
47 throw new Error(
48 `did not find window.errorLoad, current url: ${await browser.url()}`
49 )
50 }
51
52 if (isDev) break
53 }
54 }
55
56 if (!isExport) {
57 it('should normalize repeated slashes in redirects correctly', async () => {
58 const res = await fetchViaHTTP(
59 appPort,
60 '/redirect-forward-slashes',
61 undefined,
62 {
63 redirect: 'manual',
64 }
65 )
66
67 expect(res.status).toBe(307)
68 const parsedUrl = new URL(res.headers.get('location'))
69
70 expect(parsedUrl.hostname).toBeOneOf(['localhost', '127.0.0.1'])
71 expect(parsedUrl.pathname).toBe('/test/google.com')
72 expect(Object.fromEntries(parsedUrl.searchParams.entries())).toEqual({})
73 expect(await res.text()).toBe('/test/google.com')
74
75 const res2 = await fetchViaHTTP(
76 appPort,
77 '/redirect-back-slashes',
78 undefined,
79 {
80 redirect: 'manual',
81 }
82 )
83
84 expect(res2.status).toBe(307)

Callers 1

devStartAndExportFunction · 0.70

Calls 11

fetchViaHTTPFunction · 0.90
checkFunction · 0.90
webdriverFunction · 0.85
didNotReloadFunction · 0.85
escapeRegexFunction · 0.85
evalMethod · 0.80
getMethod · 0.65
textMethod · 0.65
itFunction · 0.50
expectFunction · 0.50
entriesMethod · 0.45

Tested by

no test coverage detected