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

Tests crash when requiring React Addons #54

Closed
feifanzhou opened this issue May 28, 2014 · 9 comments
Closed

Tests crash when requiring React Addons #54

feifanzhou opened this issue May 28, 2014 · 9 comments

Comments

@feifanzhou
Copy link

npm test throws "cannot read property ref of null" when my test requires React addons

# Coffeescript
describe 'Root', ->
    it 'should switch content when navigating', ->
        React = require 'react/addons'

Running on OS X Mavericks
npm -v 1.4.9
node -v 0.10.28

Full stacktrace:
http://pastebin.com/aCgmYcuv

feifanzhou added a commit to feifanzhou/Tunetap-demo that referenced this issue May 28, 2014
Issue loading React add ons: jestjs/jest#54
@vjeux
Copy link
Contributor

vjeux commented May 28, 2014

I got the same issue and fixed it by unmocking React. See http://facebook.github.io/jest/docs/tutorial-react.html#setup Can you tell me if it fixes it

@feifanzhou
Copy link
Author

Fantastic — that works, thanks! Is it a bug to be fixed, or is it intentional (and should be documented)?

@vjeux
Copy link
Contributor

vjeux commented May 28, 2014

This is intentional, React is not meant to be mocked when tested against. But we can definitively do a better job at failing when it's not the case. This error is very cryptic

@jeffmo
Copy link
Contributor

jeffmo commented May 28, 2014

Yea, I've been tracking this confusing error message here: #14

This week and last have been super busy for me, so I haven't had a chance to dive in to it just yet, but I'll throw it to the top of the queue since I think it should be a fairly simple fix.

If you have further questions or concerns, lets continue the thread in #14 to keep things centralized.

@jeffmo jeffmo closed this as completed May 28, 2014
@feifanzhou
Copy link
Author

Sounds good. I'd seen that issue earlier, but the title is misleading (in this case, there's nothing to do with module.exports). Maybe the scope/wording of #14 can be expanded?

@jeffmo
Copy link
Contributor

jeffmo commented May 28, 2014

That's a good point -- I'll update the title

@mindjuice
Copy link

I am seeing what appears to be the same issue in Jest V0.4, but I've added the unockedModulePathPatterns entry as @vjeux suggested. Here is the jest section from my package.json file:

"jest": {
  "scriptPreprocessor": "<rootDir>/preprocessor.js",
  "unmockedModulePathPatterns": [
    "<rootDir>/node_modules/react"
  ],
  "testFileExtensions": [
    "js"
  ],
  "moduleFileExtensions": [
    "js",
    "json"
  ]

I'm just using the test files at the moment with the CheckboxWithLabel component, and it is seg faulting. I'm just following this example: https://facebook.github.io/jest/docs/tutorial-react.html#content

node -v
v0.12.0

npm -v
2.5.1

jest -v
v0.4.0

@mindjuice
Copy link

Seems I am probably seeing #243 / #266

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants