-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
"cannot read property ref of null" error when module.exports === undefined #14
Comments
I've also run into this problem with a different module (not React). It's really confusing and unclear how to fix it.
|
I just committed 3e5ddee (and published v0.1.15) which should make the module mocker more accurately pass through I also considered making jest throw with an error that suggests that, when var createClass = require('createClass');
module.exports = createClass({ /*...*/ }); But I suppose this could false positive in the extremely rare case where someone, for some reason, intentionally (or non-erroneously) set their exports object to I'm not necessarily unwilling to do this -- but I do think errors of this type should surface a more debuggable stack trace now with error messages more along the lines of If this continues to be a source of pain and we keep getting questions about this, I'm willing to re-consider short-circuiting intentional |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
It only happens every so often, but it's super confusing and hard to debug when it does:
If ever a module were to somehow clobber it's exports object with something that isn't an object, you get a nasty error like this:
Let's add an assertion earlier on to ensure that the error message is at least helpful.
A common scenario where people hit this is when they're trying to test a react component that look something like this:
In this case, if you don't explicitly mark the
React
module as unmocked,module.exports
is assigned the return value ofReact.createClass()
-- which is a mock function, and thus returnsundefined
.The text was updated successfully, but these errors were encountered: