Hello!
I'm facing problem with super slow test running in jest.
I have noticed, that one simple test can take about 2 min.
Next time it will work faster, but if I change code in the test file, I have to wait again about 2 min.
I tried jest-cli version 0.9 and 0.10: no difference, both slow.
Also when I run test with --watch, it stuck.
My environment
node: v4.4.0
npm: 2.14.20
package.json
"devDependencies": {
"babel-jest": "^9.0.1",
"jest-cli": "^0.10.0"
},
"scripts": {
"test": "NODE_ENV=test jest"
},
"babel": {
"presets": [
"es2015",
"react",
"stage-0"
],
"plugins": [
"transform-decorators-legacy"
]
},
"jest": {
"testFileExtensions": [
"js"
],
"testPathDirs": [
"src/scripts/__tests__"
],
"moduleFileExtensions": [
"js"
],
"unmockedModulePathPatterns": [
"node_modules/baobab",
"node_modules/baobab-react/decorators",
"node_modules/es6-promise",
"node_modules/jquery",
"node_modules/lodash.filter",
"node_modules/lodash.isempty",
"node_modules/lodash.isundefined",
"node_modules/lodash.map",
"node_modules/lodash.sortby",
"node_modules/paqmind.data-lens",
"node_modules/q",
"node_modules/ramda",
"node_modules/react",
"node_modules/react-addons-test-utils",
"node_modules/react-bootstrap",
"node_modules/react-dom",
"node_modules/react-widgets"
]
}
Example of test
describe("Test", function() {
it("simple", function () {
expect(1).toBe(1);
});
});
Result:
Using Jest CLI v0.10.0, jasmine2, babel-jest
PASS src/scripts/__tests__/app/helpers/test.js (120.947s)
1 test passed (1 total in 1 test suite, run time 130.6s)
Do you have any ideas why it can happen?
Hello!
This is most definitely not normal and I'm unable to reproduce this locally. If this happens only on the first run, it most likely means that your babel configuration is messed up and that babel is doing something that it should not. On the first run, babel transforms all files under test.
Your package.json specifies a bunch of presets for babel, they don't however seem to be installed. I recommend reading up on the babel documentation here: http://babeljs.io/docs/plugins/#presets
To prove that this is indeed a babel problem, I recommend doing rm -rf node_modules/babel-jest and then running Jest – if the test runs significantly faster (less than 1s as expected), it is definitely a babel problem. Your test file doesn't currently seem to use any babel transforms either.
I'm closing this because it's unlikely that it is a Jest issue, but happy to reopen if it turns out to be related to Jest.
Thank you. I think you are right! After i deleted babel-jest, it works very fast. Will investigate more how to solve it. Thanks again.
Just for the history: the reason was in the slow hard drive.
After "million" experiments with different node modules (installation/deinstallation), my drive was completely fragmented. After defragmentation everything works quickly.
P.S. Using OS X, NOT SSD.
Thank you for the update! That's definitely reassuring :)
Most helpful comment
Thank you. I think you are right! After i deleted
babel-jest, it works very fast. Will investigate more how to solve it. Thanks again.