Reputation: 827
I'm trying to set up Jest in a new React project.
package.json:
"dependencies" : {
"react": "^0.13.1",
"jest-cli": "^0.4.5",
"babel-jest": "^5.2.0"
},
"scripts": {
"test": "jest"
},
"jest": {
"scriptPreprocessor": "<rootDir>/static/preprocessor.js",
"unmockedModulePathPatterns": ["react"],
"testFileExtensions": [
"js",
"jsx"
],
"moduleFileExtensions": [
"js",
"json",
"jsx"
],
"testPathDirs": [
"<rootDir>/static/app"
],
"testDirectoryName": "test",
"testPathIgnorePatterns": [
"/node_modules/",
"/bower_components/"
]
}
Test-test.js:
jest.dontMock('../scripts/components/shared/Test');
describe('Test', () => {
var Test = require('../scripts/components/shared/Test');
it('registers test', () => {
expect("yes").toEqual("yes");
});
});
Test.jsx:
var React = require('react');
When I run npm test
on the above, I get the following:
My-MacBook-Pro:project user$ npm test
> [email protected] test /Users/user/Projects/project
> jest
Using Jest CLI v0.4.5
Waiting on 1 test...My-MacBook-Pro:project user$
If I change Test.jsx to require('lodash')
, I get the following:
My-MacBook-Pro:project user$ npm test
> [email protected] test /Users/user/Projects/project
> jest
Using Jest CLI v0.4.5
PASS static/app/test/Test-test.js (0.517s)
1 test passed (1 total)
Run time: 0.731s
My-MacBook-Pro:project user$
It seems that adding 'react' module causes Jest to crash (without any logging in terminal). I suspect there's something wrong with my configuration, but I can't seem to find what.
Also, is there a way to get more verbose logging? Right now it crashes with no output... I bet I could investigate better if I had some kind of output.
Upvotes: 2
Views: 661