From c3950e3266e5820e09ad6b188d38b2473584e3f5 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 1 Jul 2021 11:35:40 -0500 Subject: [PATCH] Stabilize custom-error test --- .../test/index.test.js | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/integration/custom-error-page-exception/test/index.test.js b/test/integration/custom-error-page-exception/test/index.test.js index c95c35ec35cda..21f53de98ee9a 100644 --- a/test/integration/custom-error-page-exception/test/index.test.js +++ b/test/integration/custom-error-page-exception/test/index.test.js @@ -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/ + ) }) })