Skip to content
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

Merged
merged 2 commits into from Jul 11, 2018

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Jul 11, 2018

Resolves #11019. Replaces #13192.

@pull-bot
Copy link

pull-bot commented Jul 11, 2018

Details of bundled changes.

Comparing: afd4649...e3f3354

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-test-utils.development.js +4.4% +2.2% 42.86 KB 44.76 KB 11.92 KB 12.19 KB UMD_DEV
react-dom-test-utils.development.js +4.5% +2.3% 42.58 KB 44.48 KB 11.85 KB 12.12 KB NODE_DEV
ReactTestUtils-dev.js +0.5% +0.5% 41.43 KB 41.64 KB 11.23 KB 11.29 KB FB_WWW_DEV

Generated by 🚫 dangerJS

false,
'ReactTestUtils.mockComponent() is deprecated. ' +
'We recommend using shallow rendering or jest.mock() instead.',
);
Copy link
Contributor

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.

Copy link
Contributor Author

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 😄

@bvaughn bvaughn merged commit d64d1dd into facebook:master Jul 11, 2018
@bvaughn bvaughn deleted the deprecate-test-utils-mockComponent branch July 11, 2018 17:18
ReactTestUtils.mockComponent(MockedComponent),
).toLowPriorityWarnDev(
'ReactTestUtils.mockComponent() is deprecated. ' +
'Use shallow rendering or jest.mock() instead.',
Copy link
Collaborator

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(
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up PR #13194

@gaearon gaearon mentioned this pull request Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants