-
Notifications
You must be signed in to change notification settings - Fork 48.6k
Don't make mockComponent depend on Jest #2499
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
Comments
👍 |
Agreed, React seems to assume Jest for testing. |
Seems we can use rewire to replace the
However, we hope the |
👍 |
1 similar comment
👍 |
👍 |
This will be equally tough to break free from The challenge of breaking free from mockComponent: function(module, mockTagName) {
mockTagName = mockTagName || module.mockTagName || "div";
sinon.stub(module.prototype, "render", function() {
return React.createElement(
mockTagName,
null,
this.props.children
);
});
return this;
}, It almost feels as if this |
|
Is there any plan to remove |
@oveddan 👍 thanks, works perfectly |
Our preferred way of testing React is now using shallow rendering. http://facebook.github.io/react/docs/test-utils.html#shallow-rendering This doesn't suffer from the need to mock your components, and even if you do it doesn't do anything. |
This is very useful. But according to the docs it is still an experimental feature. Is the docs going to be changed soon? |
We'll investigate shallow rendering - we were a little surprised to find Jest dependencies in React's test utils. Please either document the dependency or (much preferred please) don't depend on Jest. We believe that there are still cases where shallow rendering isn't appropriate and it'd be great to have some guidance on how best to mock components in this case, React's testing page would be the clear place to explain this. |
Closing in favor of #11019. |
I was expecting to use
mockComponent
like this:https://github.com/facebook/react/blob/v0.12.0/src/test/ReactTestUtils.js#L244
But after looking at the source of
mockComponent
it requires to be passed aJest
mock. I already usenode-jasmine
as my test runner.Why does this depend on Jest?
The text was updated successfully, but these errors were encountered: