Even the simplest project, as described in the _Getting Started_ guide now fails.
Create the sample project (sum.js and sum.spec.js) and then try to run Jest, it fails with Couldn't find preset "es2015" relative to directory "/Users/ianp/Projects". Or check out this gist: https://gist.github.com/0e44151b16718ebc83bb25efb68a9395 .
In the debug configuration (below) I can see that it is setting usesBabelJest to true, although I'm not sure why that should be the base as I'm not using Babel in my project. I've tried adding usesBabelTest: false to package.json but that made no difference. I can also see that the preset seems to be null in the configuration, which seems odd given the error message 馃
jest version = 16.0.0
test framework = jasmine2
config = {
"rootDir": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395",
"name": "-Users-ianp-Projects-0e44151b16718ebc83bb25efb68a9395",
"setupFiles": [],
"testRunner": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395/node_modules/jest-jasmine2/build/index.js",
"scriptPreprocessor": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395/node_modules/babel-jest/build/index.js",
"usesBabelJest": true,
"automock": false,
"bail": false,
"browser": false,
"cacheDirectory": "/var/folders/5p/qfkdcjcj343gnxdn0cy8_6l40000gn/T/jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"globals": {},
"haste": {
"providesModuleNodeModules": []
},
"mocksPattern": "__mocks__",
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"node"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": [],
"noStackTrace": false,
"notify": false,
"preset": null,
"preprocessorIgnorePatterns": [
"/node_modules/"
],
"resetModules": false,
"testEnvironment": "jest-environment-jsdom",
"testPathDirs": [
"/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
"testURL": "about:blank",
"timers": "real",
"useStderr": false,
"verbose": null,
"watch": false,
"cache": true,
"watchman": true,
"testcheckOptions": {
"times": 100,
"maxSize": 200
}
}
The preset must be coming from a .babelrc somewhere in your tree. If it's there, Jest will currently automatically use it.
To fix:
.babelrcDoh! there was a .babelrc file in a parent directory, not sure how that got there 馃槚
Thanks for the hint!
Most helpful comment
The preset must be coming from a
.babelrcsomewhere in your tree. If it's there, Jest will currently automatically use it.