-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import { | |
} from 'shared/ReactTypeOfWork'; | ||
import SyntheticEvent from 'events/SyntheticEvent'; | ||
import invariant from 'shared/invariant'; | ||
import lowPriorityWarning from 'shared/lowPriorityWarning'; | ||
|
||
import * as DOMTopLevelEventTypes from '../events/DOMTopLevelEventTypes'; | ||
|
||
|
@@ -309,6 +310,12 @@ const ReactTestUtils = { | |
* @return {object} the ReactTestUtils object (for chaining) | ||
*/ | ||
mockComponent: function(module, mockTagName) { | ||
lowPriorityWarning( | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Minor, but other warnings use more direct language like:
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 commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I'm happy with tweaking the wording 😄 |
||
|
||
mockTagName = mockTagName || module.mockTagName || 'div'; | ||
|
||
module.prototype.render.mockImplementation(function() { | ||
|
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