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

React examples are failing #542

Closed
adriantoine opened this issue Oct 8, 2015 · 6 comments
Closed

React examples are failing #542

adriantoine opened this issue Oct 8, 2015 · 6 comments

Comments

@adriantoine
Copy link

Hi,

I just tried to run jest examples with react:

$ cd jest/examples/react
$ npm install
$ npm run test

And I get this error:

> @ test /home/adrien/Projects/jest/examples/react
> node ../../bin/jest.js

Using Jest CLI v0.6.0-alpha
 FAIL  __tests__/CheckboxWithLabel-test.js (0.628s)
● CheckboxWithLabel › it changes the text after click
  - TypeError: /home/adrien/Projects/jest/examples/react/node_modules/react/addons.js: /home/adrien/Projects/jest/examples/react/node_modules/react/lib/ReactWithAddons.js: /home/adrien/Projects/jest/examples/react/node_modules/react/lib/LinkedStateMixin.js: /home/adrien/Projects/jest/examples/react/node_modules/react/lib/ReactLink.js: /home/adrien/Projects/jest/examples/react/node_modules/react/lib/React.js: /home/adrien/Projects/jest/examples/react/node_modules/react/lib/ReactDOM.js: /home/adrien/Projects/jest/examples/react/node_modules/react/lib/ReactDefaultInjection.js: /home/adrien/Projects/jest/examples/react/node_modules/react/lib/BeforeInputEventPlugin.js: Cannot read property 'topCompositionEnd' of undefined
        at Object.<anonymous> (node_modules/react/lib/BeforeInputEventPlugin.js:65:33)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Object.<anonymous> (node_modules/react/lib/ReactDefaultInjection.js:14:30)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Object.<anonymous> (node_modules/react/lib/ReactDOM.js:18:29)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Object.<anonymous> (node_modules/react/lib/React.js:14:16)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Object.<anonymous> (node_modules/react/lib/ReactLink.js:38:13)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Object.<anonymous> (node_modules/react/lib/LinkedStateMixin.js:15:17)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Object.<anonymous> (node_modules/react/lib/ReactWithAddons.js:21:24)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Object.<anonymous> (node_modules/react/addons.js:13:18)
        at Object.runContentWithLocalBindings (../../src/lib/utils.js:535:17)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader._execModule (../../src/HasteModuleLoader/HasteModuleLoader.js:250:9)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModule (../../src/HasteModuleLoader/HasteModuleLoader.js:922:12)
        at Loader.resourceMap._config.moduleNameMapper.forEach.Loader.requireModuleOrMock (../../src/HasteModuleLoader/HasteModuleLoader.js:960:17)
        at Spec.<anonymous> (__tests__/CheckboxWithLabel-test.js:5:17)
1 test failed, 0 tests passed (1 total)
Run time: 1.213s

npm ERR! Linux 3.16.0-50-generic
npm ERR! argv "/usr/local/bin/iojs" "/home/adrien/.npm/bin/npm" "run" "test"
npm ERR! node v4.1.1
npm ERR! npm  v3.3.5
npm ERR! code ELIFECYCLE
npm ERR! @ test: `node ../../bin/jest.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ test script 'node ../../bin/jest.js'.
npm ERR! This is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ../../bin/jest.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/adrien/Projects/jest/examples/react/npm-debug.log

Note that if I force the react version to 0.13.3, it works fine, so the issue is probably due to React 0.14.0.
It might be because react-tools is deprecated: https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html#deprecation-of-react-tools and this example uses react-tools to transform jsx.

EDIT:
The react-es6 example works because it's using react 0.13.x but if I change it to 0.14.x here:
https://github.com/facebook/jest/blob/master/examples/react-es6/package.json#L3
I have the exact same error as above, and this one doesn't use react-tools (by the way, it should be removed from this package.json because it's not used in this example).

So it seems that jest doesn't work with react 0.14.0.

@cpojer
Copy link
Member

cpojer commented Oct 13, 2015

It definitely does work with 0.14 but we haven't had time to update the jest examples. Feel free to send us a pull request! :)

@cpojer
Copy link
Member

cpojer commented Oct 14, 2015

This should be fixed with #550

@cpojer cpojer closed this as completed Oct 14, 2015
@adriantoine
Copy link
Author

Ok thanks! The examples are still failing on my computer but it seems that I'm the only one having this issue, I'll investigate.

@cpojer
Copy link
Member

cpojer commented Oct 15, 2015

If you clone jest from master and try the examples from there, do they work?

@gregziegan
Copy link

Cloning right now from master and trying to run the examples: everything works except for the React examples. It reports a syntax error for the JSX notation. The JSX files must not be properly transpiling to ES5.

By downgrading to babel-jest below 6.0, the react tests pass.

@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

3 participants