Stabilize another test (#15697)

Saw this one fail on azure
This commit is contained in:
Jan Potoms 2020-07-31 05:22:32 +02:00 committed by GitHub
parent 766fef2271
commit d97d045dfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@ import {
launchApp, launchApp,
killApp, killApp,
waitFor, waitFor,
check,
} from 'next-test-utils' } from 'next-test-utils'
jest.setTimeout(1000 * 60 * 2) jest.setTimeout(1000 * 60 * 2)
@ -49,20 +50,24 @@ describe('Empty Project', () => {
it('should show empty object warning during client transition', async () => { it('should show empty object warning during client transition', async () => {
const browser = await webdriver(appPort, '/static') const browser = await webdriver(appPort, '/static')
await browser.eval(`(function() { try {
window.gotWarn = false await browser.eval(`(function() {
const origWarn = console.warn window.gotWarn = false
window.console.warn = function () { const origWarn = console.warn
if (arguments[0].match(/returned an empty object from \`getInitialProps\`/)) { window.console.warn = function () {
window.gotWarn = true if (arguments[0].match(/returned an empty object from \`getInitialProps\`/)) {
window.gotWarn = true
}
origWarn.apply(this, arguments)
} }
origWarn.apply(this, arguments) window.next.router.replace('/another')
} })()`)
window.next.router.replace('/another') await check(async () => {
})()`) const gotWarn = await browser.eval(`window.gotWarn`)
await waitFor(1000) return gotWarn ? 'pass' : 'fail'
const gotWarn = await browser.eval(`window.gotWarn`) }, 'pass')
expect(gotWarn).toBe(true) } finally {
await browser.close() await browser.close()
}
}) })
}) })