我最近从Mocha转到了Jest。除了始终运行所有测试的监视模式(不仅仅是与文档中所述的未提交文件相关的测试)外,一切正常。我已经搜索了文档和Google,但我没有找到有关此问题的任何信息。
我的jest配置是
"jest": {
"coveragePathIgnorePatterns": [
"/node_modules/",
"/generated/",
"/mock/",
"/tools/",
"/transactions/"
],
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 90,
"lines": 90,
"statements": 90
}
},
"resetMocks": true,
"moduleDirectories": [
"node_modules",
"src"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
"\\.(css|less|scss)$": "<rootDir>/src/__mocks__/styleMock.js"
},
"setupTestFrameworkScriptFile": "<rootDir>/tools/setupTest.js"
},
setupTestFrameworkScriptFile
只包含一行:
require('babel-polyfill');
Babelrc:
"env": {
"test": {
"plugins": [
"rewire",
"transform-class-properties",
"transform-es2015-modules-commonjs"
],
"presets": [
"es2017",
"react",
"stage-0",
"es2015"
]
}
}
我使用jest --watch
开始测试,并打印消息“确定要运行的测试套件”,但所有测试都运行,即使没有文件未被提供。
我在Windows 7上,我在powershell中运行命令。节点版本:v6.9.1
开玩笑版本:"babel-jest": "20.0.3"
,"jest": "20.0.4"
答案 0 :(得分:0)
老实说,我猜,但是除了coveragePathIgnorePatterns之外,请尝试使用testPathIgnorePatterns。