我正在使用以下 jest.unittest.json 文件(通过 jest --config 选项使用):
{
"bail": false,
"verbose": true,
"transform": {
"^.+\\.(ts|tsx)$": "typescript-babel-jest"
},
"testPathIgnorePatterns": [
"<rootDir>/lib",
"<rootDir>/lib_es6",
"/node_modules/",
"fixtures.ts",
"/fixtures/"
],
"moduleFileExtensions": [
"js", "jsx", "ts", "tsx", "node"
],
"roots": [
"<rootDir>/src/__unittests__/Logger",
"<rootDir>/src/__unittests__/Renderer/renderer.test.ts"
],
"testRegex": "<rootDir>/src/__unittests__/.*\\.test.(ts|tsx|js|jsx)$"
}
注意测试文件是 src/单元测试 /Renderer/renderer.test.ts,等等。
它曾经在 jest v19 之前有效,但升级到 v20 后,此配置不再有效。
当我 jest --config jest.unittest.json --verbose 时,我得到:
Pattern: "" - 0 matches
我的配置有问题吗?
最佳答案
尝试改变 testRegex
到这样的事情:"(/src/__unittests__/.*|\\.(test|spec))\\.(ts|tsx|js)$"
关于jestjs - Jest 模式 ""- 0 个匹配(从 jest 19 -> jest 20 移动),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44328549/