()
| 15 | let appPort |
| 16 | |
| 17 | const 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() |
no test coverage detected