| 16 | let app |
| 17 | |
| 18 | const runTests = () => { |
| 19 | it('Supports commonjs 1', async () => { |
| 20 | const browser = await webdriver(appPort, '/commonjs1') |
| 21 | const html = await browser.eval('document.body.innerHTML') |
| 22 | expect(html).toMatch(/test1/) |
| 23 | expect(html).toMatch(/nextExport/) |
| 24 | await browser.close() |
| 25 | }) |
| 26 | |
| 27 | it('Supports commonjs 2', async () => { |
| 28 | const browser = await webdriver(appPort, '/commonjs2') |
| 29 | const html = await browser.eval('document.body.innerHTML') |
| 30 | expect(html).toMatch(/test2/) |
| 31 | expect(html).toMatch(/nextExport/) |
| 32 | await browser.close() |
| 33 | }) |
| 34 | |
| 35 | it('Refreshes query on mount', async () => { |
| 36 | const browser = await webdriver(appPort, '/post-1') |
| 37 | await check(() => browser.eval('document.body.innerHTML'), /post.*post-1/) |
| 38 | const html = await browser.eval('document.body.innerHTML') |
| 39 | expect(html).toMatch(/nextExport/) |
| 40 | }) |
| 41 | |
| 42 | it('should update asPath after mount', async () => { |
| 43 | const browser = await webdriver(appPort, '/zeit/cmnt-2') |
| 44 | await check( |
| 45 | () => browser.eval(`document.documentElement.innerHTML`), |
| 46 | /\/zeit\/cmnt-2/ |
| 47 | ) |
| 48 | }) |
| 49 | |
| 50 | it('should not replace URL with page name while asPath is delayed', async () => { |
| 51 | const browser = await webdriver(appPort, '/zeit/cmnt-1') |
| 52 | const val = await browser.eval(`!!window.pathnames.find(function(p) { |
| 53 | return p !== '/zeit/cmnt-1' |
| 54 | })`) |
| 55 | expect(val).toBe(false) |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | describe('Auto Export', () => { |
| 60 | ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( |