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

Function runTests

test/integration/no-page-props/test/index.test.ts:17–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15let appPort
16
17const runTests = () => {
18 it('should load auto-export page correctly', async () => {
19 const browser = await webdriver(appPort, '/')
20 expect(await browser.elementByCss('#index').text()).toBe('index')
21 expect(await browser.eval('window.uncaughtErrors')).toEqual([])
22 })
23
24 it('should load getStaticProps page correctly', async () => {
25 const browser = await webdriver(appPort, '/gsp')
26 expect(await browser.elementByCss('#gsp').text()).toBe('getStaticProps')
27 expect(await browser.eval('window.uncaughtErrors')).toEqual([])
28 })
29
30 it('should load getServerSideProps page correctly', async () => {
31 const browser = await webdriver(appPort, '/gssp')
32 expect(await browser.elementByCss('#gssp').text()).toBe(
33 'getServerSideProps'
34 )
35 expect(await browser.eval('window.uncaughtErrors')).toEqual([])
36 })
37
38 it('should load 404 page correctly', async () => {
39 const browser = await webdriver(appPort, '/non-existent')
40 expect(await browser.elementByCss('h2').text()).toBe(
41 'Application error: a client-side exception has occurred (see the browser console for more information).'
42 )
43 expect(await browser.eval('window.uncaughtErrors')).toEqual([])
44 })
45
46 it('should navigate between pages correctly', async () => {
47 const browser = await webdriver(appPort, '/')
48
49 await browser.eval('window.beforeNav = "hi"')
50 await browser.elementByCss('#to-gsp').click()
51 await browser.waitForElementByCss('#gsp')
52
53 expect(await browser.elementByCss('#gsp').text()).toBe('getStaticProps')
54 expect(await browser.eval('window.beforeNav')).toBe('hi')
55
56 await browser.back()
57 await browser.waitForElementByCss('#index')
58 expect(await browser.eval('window.beforeNav')).toBe('hi')
59
60 await browser.elementByCss('#to-gssp').click()
61 await browser.waitForElementByCss('#gssp')
62
63 expect(await browser.elementByCss('#gssp').text()).toBe(
64 'getServerSideProps'
65 )
66 expect(await browser.eval('window.beforeNav')).toBe('hi')
67
68 await browser.back()
69 await browser.waitForElementByCss('#index')
70 expect(await browser.eval('window.beforeNav')).toBe('hi')
71
72 await browser.elementByCss('#to-404').click()
73 await browser.waitForElementByCss('h2')
74 expect(await browser.eval('window.beforeNav')).toBeFalsy()

Callers 1

index.test.tsFile · 0.70

Calls 9

webdriverFunction · 0.85
elementByCssMethod · 0.80
evalMethod · 0.80
clickMethod · 0.80
waitForElementByCssMethod · 0.80
textMethod · 0.65
backMethod · 0.65
itFunction · 0.50
expectFunction · 0.50

Tested by

no test coverage detected