-
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
Deprecate ReactTestUtils.mockComponent() #13193
Changes from all commits
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( | ||
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. 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Follow up PR #13194 |
||
false, | ||
'ReactTestUtils.mockComponent() is deprecated. ' + | ||
'Use shallow rendering or jest.mock() instead.', | ||
); | ||
|
||
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.
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.