-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
Deprecate ReactTestUtils.mockComponent() #13193
Deprecate ReactTestUtils.mockComponent() #13193
Conversation
Details of bundled changes.Comparing: afd4649...e3f3354 react-dom
Generated by 🚫 dangerJS |
false, | ||
'ReactTestUtils.mockComponent() is deprecated. ' + | ||
'We recommend using shallow rendering or jest.mock() instead.', | ||
); |
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.
Minor, but other warnings use more direct language like:
"ReactTestUtils.mockComponent() is deprecated. Use shallow rendering or jest.mock() instead."`.
This isn't a hard recommendation, so I think softening it a bit makes sense, but it just crossed my mind.
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.
Cool, I'm happy with tweaking the wording 😄
ReactTestUtils.mockComponent(MockedComponent), | ||
).toLowPriorityWarnDev( | ||
'ReactTestUtils.mockComponent() is deprecated. ' + | ||
'Use shallow rendering or jest.mock() instead.', |
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 add an fb.me link that either points to a gist or a warning page with a drop-in replacement code? People who rely on it might not understand what mockComponent was doing exactly.
@@ -309,6 +310,12 @@ const ReactTestUtils = { | |||
* @return {object} the ReactTestUtils object (for chaining) | |||
*/ | |||
mockComponent: function(module, mockTagName) { | |||
lowPriorityWarning( |
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 needs to be behind a duplicate check. Otherwise it might significantly spam console in tests.
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.
👍 Sure
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.
Follow up PR #13194
Resolves #11019. Replaces #13192.