Unverified Commit bc845f22 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Stabilize HMR tests on CI (#12029)

parent 450d4bd0
...@@ -213,6 +213,12 @@ function handleErrors(errors) { ...@@ -213,6 +213,12 @@ function handleErrors(errors) {
// Do not attempt to reload now. // Do not attempt to reload now.
// We will reload on next success instead. // We will reload on next success instead.
if (process.env.__NEXT_TEST_MODE) {
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB(formatted.errors[0])
self.__NEXT_HMR_CB = null
}
}
} }
function tryDismissErrorOverlay() { function tryDismissErrorOverlay() {
......
...@@ -69,7 +69,7 @@ export async function sandbox(id = nanoid()) { ...@@ -69,7 +69,7 @@ export async function sandbox(id = nanoid()) {
console.log('Application re-loaded.') console.log('Application re-loaded.')
// Slow down tests a bit: // Slow down tests a bit:
await new Promise(resolve => setTimeout(resolve, 250)) await new Promise(resolve => setTimeout(resolve, 750))
return false return false
} }
if (status === 'success') { if (status === 'success') {
...@@ -83,8 +83,8 @@ export async function sandbox(id = nanoid()) { ...@@ -83,8 +83,8 @@ export async function sandbox(id = nanoid()) {
await new Promise(resolve => setTimeout(resolve, 30)) await new Promise(resolve => setTimeout(resolve, 30))
} }
// Slow down tests a bit: // Slow down tests a bit (we don't know how long re-rendering takes):
await new Promise(resolve => setTimeout(resolve, 250)) await new Promise(resolve => setTimeout(resolve, 750))
return true return true
}, },
async remove(fileName) { async remove(fileName) {
...@@ -103,6 +103,16 @@ export async function sandbox(id = nanoid()) { ...@@ -103,6 +103,16 @@ export async function sandbox(id = nanoid()) {
) )
} }
}, },
async getOverlayContent() {
await browser.waitForElementByCss('iframe', 10000)
const hasIframe = await browser.hasElementByCssSelector('iframe')
if (!hasIframe) {
throw new Error('Unable to find overlay')
}
return browser.eval(
`document.querySelector('iframe').contentWindow.document.body.innerHTML`
)
},
}, },
function cleanup() { function cleanup() {
async function _cleanup() { async function _cleanup() {
......
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