-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
[code-infra] Fix StrictMode effects not being called twice in React 19 tests
#45812
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
[code-infra] Fix StrictMode effects not being called twice in React 19 tests
#45812
Conversation
reactStrictMode from @testing-library/reactStrictMode not being enabled for React 19 tests
StrictMode not being enabled for React 19 testsStrictMode effects not being called twice in React 19 tests
Netlify deploy previewhttps://deploy-preview-45812--material-ui.netlify.app/ Bundle size report |
6aa514f to
99bc517
Compare
| ], | ||
| // detect-modules doesn't work with @babel/register | ||
| // https://github.com/babel/babel/issues/6737 | ||
| 'node-option': ['no-experimental-detect-module'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cherry-picked from 0f92cc3 (#45630)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks again in Node 23, but ok, let's worry about that later
b474437 to
61128ac
Compare
3b6b562 to
615c6b7
Compare
615c6b7 to
03b54bc
Compare
03b54bc to
fba032e
Compare
|
@bernardobelchior Should we merge #45828? |
We can. I'll just rebase this PR. |
fba032e to
2ac5088
Compare
2ac5088 to
a90ab11
Compare
a90ab11 to
9c66533
Compare
Related to testing-library/react-testing-library#1390.
In React 19,
StrictModewon't double-call effects on initial mount unlessStrictModeis at the root of the app. Our previous way of enablingStrictModecreated aWrapper, meaning that theWrappercomponent was at the root of the app, resulting in the double calling of effects not happening in initial mount in React 19.This PR uses the new property
reactStrictModefrom@testing-library/reactto enable double-calling on initial mount in React 19 tests.This option was introduced in this PR, that's why I also upgraded the dependency.
This PR also changes some tests. In the ones I was most confident, I actually updated the assertions. For the ones I wasn't, I disabled strict mode for that particular test in React 19. If you know how to fix it, please let me know 😄