Unverified Commit 1c45f709 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

[test] Update hydration marker for React 17 (#16756)

parent d20dbd6c
...@@ -151,14 +151,6 @@ class Container extends React.Component<{ ...@@ -151,14 +151,6 @@ class Container extends React.Component<{
} }
) )
} }
if (process.env.__NEXT_TEST_MODE) {
window.__NEXT_HYDRATED = true
if (window.__NEXT_HYDRATED_CB) {
window.__NEXT_HYDRATED_CB()
}
}
} }
componentDidUpdate() { componentDidUpdate() {
...@@ -719,5 +711,15 @@ function Root({ ...@@ -719,5 +711,15 @@ function Root({
// We use `useLayoutEffect` to guarantee the callback is executed // We use `useLayoutEffect` to guarantee the callback is executed
// as soon as React flushes the update. // as soon as React flushes the update.
React.useLayoutEffect(() => callback(), [callback]) React.useLayoutEffect(() => callback(), [callback])
if (process.env.__NEXT_TEST_MODE) {
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
window.__NEXT_HYDRATED = true
if (window.__NEXT_HYDRATED_CB) {
window.__NEXT_HYDRATED_CB()
}
}, [])
}
return children as React.ReactElement return children as React.ReactElement
} }
...@@ -37,10 +37,6 @@ export async function sandbox( ...@@ -37,10 +37,6 @@ export async function sandbox(
env: { __NEXT_TEST_WITH_DEVTOOL: 1 }, env: { __NEXT_TEST_WITH_DEVTOOL: 1 },
}) })
const browser = await webdriver(appPort, '/') const browser = await webdriver(appPort, '/')
// Slow down tests a bit to ensure application is ready:
await new Promise((resolve) => setTimeout(resolve, 750))
return [ return [
{ {
sandboxDirectory, sandboxDirectory,
......
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