Skip to content

Commit

Permalink
Stabilize another test (vercel#15697)
Browse files Browse the repository at this point in the history
Saw this one fail on azure
  • Loading branch information
Janpot authored Jul 31, 2020
1 parent 766fef2 commit d97d045
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions test/integration/empty-object-getInitialProps/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
launchApp,
killApp,
waitFor,
check,
} from 'next-test-utils'

jest.setTimeout(1000 * 60 * 2)
Expand Down Expand Up @@ -49,20 +50,24 @@ describe('Empty Project', () => {

it('should show empty object warning during client transition', async () => {
const browser = await webdriver(appPort, '/static')
await browser.eval(`(function() {
window.gotWarn = false
const origWarn = console.warn
window.console.warn = function () {
if (arguments[0].match(/returned an empty object from \`getInitialProps\`/)) {
window.gotWarn = true
try {
await browser.eval(`(function() {
window.gotWarn = false
const origWarn = console.warn
window.console.warn = function () {
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')
})()`)
await waitFor(1000)
const gotWarn = await browser.eval(`window.gotWarn`)
expect(gotWarn).toBe(true)
await browser.close()
window.next.router.replace('/another')
})()`)
await check(async () => {
const gotWarn = await browser.eval(`window.gotWarn`)
return gotWarn ? 'pass' : 'fail'
}, 'pass')
} finally {
await browser.close()
}
})
})

0 comments on commit d97d045

Please sign in to comment.