-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
ReactDOM: Remove every test-util except act()
#28541
Conversation
Comparing: 4cc0f8e...82e3562 Critical size changesIncludes critical production bundles, as well as any change greater than 2%: Significant size changesIncludes any change greater than 0.2%: Expand to show
|
5c74ee7
to
5fc850d
Compare
I looked into vendoring ReactTestUtils in WWW to avoiding needing additional gating here but it has too much internal usage for it to be stable. Can we apply either gating on the utils functions themselves or a build fork of the whole module? And additionally can we keep the ReactTestUtils-test with gating for www? Let me know if you want help with the additional work here. Ideally within a couple months we can fully remove. |
We use special |
e36702e
to
f5c3394
Compare
Didn't go with the special |
65cf02e
to
ce7a436
Compare
if (disableDOMTestUtils) { | ||
throw new Error( | ||
'`renderIntoDocument` was removed from `react-dom/test-utils`. ' + | ||
'See https://react.dev/warnings/react-test-renderer for more info.', |
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.
TODO: Write docs
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.
Should we generalize this warning page to something like /warnings/testing
and include sections for each separate warning between ReactTestUtils and react-test-renderer?
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.
I'd probably have a page for test-renderer and test-utils
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.
Docs: reactjs/react.dev#6716
if (disableDOMTestUtils) { | ||
throw new Error( | ||
'`renderIntoDocument` was removed from `react-dom/test-utils`. ' + | ||
'See https://react.dev/warnings/react-test-renderer for more info.', |
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.
Should we generalize this warning page to something like /warnings/testing
and include sections for each separate warning between ReactTestUtils and react-test-renderer?
@@ -102,6 +102,7 @@ export const disableStringRefs = false; | |||
|
|||
export const enableReactTestRendererWarning = false; | |||
export const disableLegacyMode = false; | |||
export const disableDOMTestUtils = true; |
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.
Let's keep this false for now so this is easier to land.
ce7a436
to
6f3b264
Compare
c75f7d6
to
82e3562
Compare
Summary
Removes every API from
react-dom/test-utils
exceptact
in favor of using@testing-library/react
. Removal is gated behinddisableDOMTestUtils
that's off for Meta builds.The functions aren't removed but instead throw with a helpful error message. We're doing the same for
ReactDOM.render
.Also reverts #28446 to restore test coverage.
Some APIs like
renderIntoDocument
are technically gated behinddisableDOMTestUtils
anddisableLegacyRoot
. We could just combine both flags to prevent drift.How did you test this change?
yarn test ReactTestUtils-test