mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Deprecate ReactTestUtils.mockComponent() (#13193)
Deprecate ReactTestUtils.mockComponent()
This commit is contained in:
1 parent
afd46490d0
commit
d64d1ddb57
2 files changed
+13
-1
No files matched your search
+6
-1
@@ -53,7 +53,12 @@ describe('ReactTestUtils', () => {
|
||||
MockedComponent.prototype.render = jest.fn();
|
||||
|
||||
// Patch it up so it returns its children.
|
||||
ReactTestUtils.mockComponent(MockedComponent);
|
||||
expect(() =>
|
||||
ReactTestUtils.mockComponent(MockedComponent),
|
||||
).toLowPriorityWarnDev(
|
||||
'ReactTestUtils.mockComponent() is deprecated. ' +
|
||||
'Use shallow rendering or jest.mock() instead.',
|
||||
);
|
||||
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<MockedComponent>Hello</MockedComponent>, container);
|
||||
|
||||
@@ -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. ' +
|
||||
'Use shallow rendering or jest.mock() instead.',
|
||||
);
|
||||
|
||||
mockTagName = mockTagName || module.mockTagName || 'div';
|
||||
|
||||
module.prototype.render.mockImplementation(function() {
|
||||
|
||||
Reference in new issue
Block a user