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

Function navigateTest

test/integration/prerender-export/test/index.test.ts:19–204  ·  view source on GitHub ↗
(dev = false)

Source from the content-addressed store, hash-verified

17let buildId
18
19const navigateTest = (dev = false) => {
20 it('should navigate between pages successfully', async () => {
21 const toBuild = [
22 '/',
23 '/another',
24 '/something',
25 '/normal',
26 '/blog/post-1',
27 '/blog/post-1/comment-1',
28 '/catchall/first',
29 ]
30
31 await waitFor(2500)
32
33 await Promise.all(toBuild.map((pg) => renderViaHTTP(appPort, pg)))
34
35 const browser = await webdriver(appPort, '/')
36 let text = await browser.elementByCss('p').text()
37 expect(text).toMatch(/hello.*?world/)
38
39 // go to /another
40 async function goFromHomeToAnother() {
41 await browser.eval('window.beforeAnother = true')
42 await browser.elementByCss('#another').click()
43 await browser.waitForElementByCss('#home')
44 text = await browser.elementByCss('p').text()
45 expect(await browser.eval('window.beforeAnother')).toBe(true)
46 expect(text).toMatch(/hello.*?world/)
47 }
48 await goFromHomeToAnother()
49
50 // go to /
51 async function goFromAnotherToHome() {
52 await browser.eval('window.didTransition = 1')
53 await browser.elementByCss('#home').click()
54 await browser.waitForElementByCss('#another')
55 text = await browser.elementByCss('p').text()
56 expect(text).toMatch(/hello.*?world/)
57 expect(await browser.eval('window.didTransition')).toBe(1)
58 }
59 await goFromAnotherToHome()
60
61 // Client-side SSG data caching test
62 {
63 // Let revalidation period lapse
64 await waitFor(2000)
65
66 // Trigger revalidation (visit page)
67 await goFromHomeToAnother()
68 const snapTime = await browser.elementByCss('#anotherTime').text()
69
70 // Wait for revalidation to finish
71 await waitFor(2000)
72
73 // Re-visit page
74 await goFromAnotherToHome()
75 await goFromHomeToAnother()
76

Callers 1

index.test.tsFile · 0.70

Calls 15

waitForFunction · 0.90
renderViaHTTPFunction · 0.90
webdriverFunction · 0.85
allMethod · 0.80
elementByCssMethod · 0.80
clickMethod · 0.80
waitForElementByCssMethod · 0.80
evalMethod · 0.80
goFromHomeToAnotherFunction · 0.70
goFromAnotherToHomeFunction · 0.70
textMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected