即使是最简单的项目,如 _Getting Started_ 指南中所述,现在也失败了。
创建示例项目( sum.js
和sum.spec.js
),然后尝试运行 Jest,它以Couldn't find preset "es2015" relative to directory "/Users/ianp/Projects"
失败。 或者查看这个要点: https :
在调试配置(如下)中,我可以看到它将usesBabelJest
为 true,尽管我不确定为什么这应该是基础,因为我没有在我的项目中使用 Babel。 我试过将usesBabelTest: false
到package.json
但这没有任何区别。 我还可以看到preset
在配置中似乎为空,鉴于错误消息,这似乎很奇怪🤔
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
}
}
预设必须来自树中某处的.babelrc
。 如果它在那里,Jest 当前将自动使用它。
修理:
.babelrc
呸! 父目录中有一个.babelrc
文件,不知道它是怎么到那里的 😖
谢谢你的提示!
最有用的评论
预设必须来自树中某处的
.babelrc
。 如果它在那里,Jest 当前将自动使用它。