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

Function runTests

test/e2e/basepath/trailing-slash.test.ts:25–93  ·  view source on GitHub ↗
(dev = false)

Source from the content-addressed store, hash-verified

23 afterAll(() => next.destroy())
24
25 const runTests = (dev = false) => {
26 it('should allow URL query strings without refresh', async () => {
27 const browser = await webdriver(next.url, `${basePath}/hello/?query=true`)
28 try {
29 await browser.eval('window.itdidnotrefresh = "hello"')
30 await new Promise((resolve, reject) => {
31 // Timeout of EventSource created in setupPing()
32 // (on-demand-entries-utils.js) is 5000 ms (see #13132, #13560)
33 setTimeout(resolve, dev ? 10000 : 1000)
34 })
35 expect(await browser.eval('window.itdidnotrefresh')).toBe('hello')
36
37 const pathname = await browser.elementByCss('#pathname').text()
38 expect(pathname).toBe('/hello')
39 expect(await browser.eval('window.location.pathname')).toBe(
40 `${basePath}/hello/`
41 )
42 expect(await browser.eval('window.location.search')).toBe('?query=true')
43
44 if (dev) {
45 await waitForNoRedbox(browser)
46 }
47 } finally {
48 await browser.close()
49 }
50 })
51
52 it('should allow URL query strings on index without refresh', async () => {
53 const browser = await webdriver(next.url, `${basePath}/?query=true`)
54 try {
55 await browser.eval('window.itdidnotrefresh = "hello"')
56 await new Promise((resolve, reject) => {
57 // Timeout of EventSource created in setupPing()
58 // (on-demand-entries-utils.js) is 5000 ms (see #13132, #13560)
59 setTimeout(resolve, dev ? 10000 : 1000)
60 })
61 expect(await browser.eval('window.itdidnotrefresh')).toBe('hello')
62
63 const pathname = await browser.elementByCss('#pathname').text()
64 expect(pathname).toBe('/')
65 expect(await browser.eval('window.location.pathname')).toBe(
66 basePath + '/'
67 )
68 expect(await browser.eval('window.location.search')).toBe('?query=true')
69
70 if (dev) {
71 await waitForNoRedbox(browser)
72 }
73 } finally {
74 await browser.close()
75 }
76 })
77
78 it('should correctly replace state when same asPath but different url', async () => {
79 const browser = await webdriver(next.url, `${basePath}/`)
80 try {
81 await browser.elementByCss('#hello-link').click()
82 await browser.waitForElementByCss('#something-else-link')

Callers 1

Calls 13

waitForNoRedboxFunction · 0.90
webdriverFunction · 0.85
evalMethod · 0.80
elementByCssMethod · 0.80
clickMethod · 0.80
waitForElementByCssMethod · 0.80
textMethod · 0.65
closeMethod · 0.65
backMethod · 0.65
forwardMethod · 0.65
itFunction · 0.50
setTimeoutFunction · 0.50

Tested by

no test coverage detected