Unverified Commit 03611eef authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update error load fail test so that webdriver can still connect to app (#10673)

parent 40abd708
/* eslint-env jest */ /* eslint-env jest */
/* global jasmine */ /* global jasmine */
import path from 'path' import { join } from 'path'
import fs from 'fs-extra'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { nextBuild, nextStart, findPort, killApp, check } from 'next-test-utils' import { nextBuild, nextStart, findPort, killApp, check } from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1
const appDir = path.join(__dirname, '..') const appDir = join(__dirname, '..')
let app
describe('Failing to load _error', () => { describe('Failing to load _error', () => {
afterAll(() => killApp(app))
it('handles failing to load _error correctly', async () => { it('handles failing to load _error correctly', async () => {
await nextBuild(appDir) await nextBuild(appDir)
const buildId = await fs.readFile(join(appDir, '.next/BUILD_ID'), 'utf8')
const appPort = await findPort() const appPort = await findPort()
const app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
const browser = await webdriver(appPort, '/') const browser = await webdriver(appPort, '/')
await browser.eval(`window.beforeNavigate = true`) await browser.eval(`window.beforeNavigate = true`)
...@@ -19,8 +24,8 @@ describe('Failing to load _error', () => { ...@@ -19,8 +24,8 @@ describe('Failing to load _error', () => {
await browser.elementByCss('#to-broken').moveTo() await browser.elementByCss('#to-broken').moveTo()
await browser.waitForElementByCss('script[src*="broken.js"') await browser.waitForElementByCss('script[src*="broken.js"')
// stop app so that _error can't be loaded // remove _error client bundle so that it can't be loaded
await killApp(app) await fs.remove(join(appDir, '.next/static/', buildId, 'pages/_error.js'))
await browser.elementByCss('#to-broken').click() await browser.elementByCss('#to-broken').click()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment