parent
766fef2271
commit
d97d045dfc
1 changed files with 19 additions and 14 deletions
|
@ -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()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue