-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress Tests are failing due to hydration error #3
Comments
My team is running into this with our E2E tests via Cypress on React 18.2.0. Our E2E tests won't work at all due to this issue. I tried @ryanyogan's suggestion in the referenced issue, but that didn't resolve the problem for me. Is there another known workaround? |
hey @wrporter, One solution, which is not really a "solution" is to downgrade the react dom client to v17 hydrate. revert entry.client.tsx to this import { RemixBrowser } from '@remix-run/react';
import { hydrate } from 'react-dom';
hydrate(<RemixBrowser />, document); Meanwhile, I'm waiting for a new React release. |
@wrporter I found a better fix.
|
The way Remix is handling this in their template projects fixed the issue for us. See how they use |
I just added the isbot case, but it's still failing without the cypress fix. |
I'm experiencing this error with Remix 1.12.0 and React 18.2.0 too in Solution (kinda of) is to run tests on a build version served with |
@alexamy you can use the intermediate fix I put above to avoid Cypress errors. |
If your tests are failing because Cypress is clicking the app before it re-hydrated, you can set a class after it re-hydrates on the root.tsx: export const App = () => {
const htmlRef = useRef<HTMLHtmlElement>(null)
useEffect(() => {
if(htmlRef.current) {
htmlRef.current.classList.add('hydrated')
}
}, [])
return (
<html ref={htmlRef} lang="en">
//...
</html>
) Then, on your Cypress tests, you could do something like: cy.visit('http://localhost:3000')
cy.get('html').should('have.class', 'hydrated')
// App rehydrated, you can now click stuff |
any update on this? |
@neelamshah02 still waiting for a new React version that will address this. |
This occurs with the latest upgrade of React to 18.2.0.
Related issues :
facebook/react#24430
remix-run/remix#2947
Waiting for a fix, if not we will revert to react 17 version of hydrate.
The text was updated successfully, but these errors were encountered: