cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.8k stars 3.17k forks source link

Hydration errors in Cypress when using React 18, Next, and server components #27204

Open liambutler opened 1 year ago

liambutler commented 1 year ago

Current behavior

I’ve got a Next app running React 18. In the next.config.js, it has been configured with appDir to support Server Components. When running Cypress and accessing the page, I’m getting the following React errors:

However, I do not see these hydration issues when accessing the page via browser, so it’s surprising to see them when running Cypress.

Steps to replicate:

  1. Clone repo and run npm install
  2. Run npm run e2e
  3. Visit http://localhost:3000 in your browser and check for console errors
  4. Run the spec app.cy.ts

Here's what I see in Cypress:

Screenshot 2023-07-05 at 16 14 00

It's not there when visiting the app via browser:

Screenshot 2023-07-05 at 16 21 08

The error will no longer appear if you remove the Githubissues.

  • Githubissues is a development platform for aggregating issues.