question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v10.4.0 Component test React 18 warnings with mid sized apps

See original GitHub issue

Current behavior

In a simple repo, like a fresh CRA, or small a-la-carte components as in 330+ cypress-react-component-test-examples v10.4.0 works as intented; there are no React 18 warnings in the console.

In mid sized or larger apps the React 18 console warnings may still persist.

Here are 2 apps where the issue is observed. Install and run any component test and view the console.

Repo 1: Kent Dodds’ Epic React final app, with Cypress e2e and component tests:

git clone https://github.com/muratkeremozcan/bookshelf.git
cd bookshelf
npm i
npm run cy:open-ct

Repo 2: React Hooks in Action book with Cypress e2e and component tests

git clone https://github.com/muratkeremozcan/react-hooks-in-action-with-cypress.git
cd react-hooks-in-action-with-cypress
yarn 
yarn cy:open-ct

clear Cypress cache, remove node_modules, clear npm / yarn cache to ensure clean installs

image

Desired behavior

Regardless of the app size, there are no React 18 console warnings and we can use new React hooks in the tests.

Test code to reproduce

Linked above.

Cypress Version

10.4.0

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lmiller1990commented, Aug 11, 2022

Headless (well “run mode” where you run all specs) execution for Component Testing will improve significantly (up to ~50% on large code bases, improvement linear based on # of specs) with an experimental flag that is landing soon.

FYI: You can also pass --headed to do a full execution with a headed browser (does not change performance).

As for the experimental feature:

I will try the experimental flag on your code base now. You can even try it by installing one of these pre-release binaries: https://github.com/cypress-io/cypress/commit/293a0f489bbbeae9ecc6d76053fa24eef77fc2de#comments. You need to enable the experiment. Example.

Edit: wow this code base is taking forever to run! I’ll get you some before/after numbers with the experimental flag. Give me a moment.

export default defineConfig({
  component: {
    experimentalSingleTabRunMode: true // <= this is the flag to enable the single tab run mode
  }
})

React 18 should be 💯 once the bug fix it out.

0reactions
lmiller1990commented, Aug 24, 2022

Hmm that’s odd, I wonder why the CDP real-events are failing 🤔

Glad the experiment is helping - if it goes well over the next few weeks and no-one reports any bugs, it may become the default. Just to clarify - are you saying the real-events library is more flaky when using the single tab experiment?

Read more comments on GitHub >

github_iconTop Results From Across the Web

v10.4.0 Component test React 18 warnings with mid sized apps
In mid sized or larger apps the React 18 console warnings may still persist. Here are 2 apps where the issue is observed....
Read more >
Testing Overview - React
This documentation section focuses on testing strategies for the first case. While full end-to-end tests can be very useful to prevent regressions to...
Read more >
Changelog - Cypress Documentation
Component tests allow you to see and test your application's components in a real browser as you work. You can use your favorite...
Read more >
React Testing Library gives console error for ReactDOM ...
To solve the react testing library error: "ReactDOM.render is no longer supported in React 18, update the version of the react testing ......
Read more >
React Testing Library - npm
The React Testing Library is a very lightweight solution for testing React components. It provides light utility functions on top of react-dom ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found