Skip to content

Commit

Permalink
Stabilize custom-error test
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jul 1, 2021
1 parent 4716f14 commit c3950e3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions test/integration/custom-error-page-exception/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

import { join } from 'path'
import webdriver from 'next-webdriver'
import { nextBuild, nextStart, findPort, killApp } from 'next-test-utils'
import { nextBuild, nextStart, findPort, killApp, check } from 'next-test-utils'

jest.setTimeout(1000 * 60 * 1)

const appDir = join(__dirname, '..')
const navSel = '#nav'
const errorMessage = 'Application error: a client-side exception has occurred'
let appPort
let app

describe('Custom error page exception', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
it('should handle errors from _error render', async () => {
const { code } = await nextBuild(appDir)
const appPort = await findPort()
const app = await nextStart(appDir, appPort)
const navSel = '#nav'
const browser = await webdriver(appPort, '/')
await browser.waitForElementByCss(navSel).elementByCss(navSel).click()
const text = await (await browser.elementByCss('#__next')).text()
killApp(app)

expect(code).toBe(0)
expect(text).toMatch(errorMessage)
await check(
() => browser.eval('document.documentElement.innerHTML'),
/Application error: a client-side exception has occurred/
)
})
})

0 comments on commit c3950e3

Please sign in to comment.