Jest testMatch无法找到任何匹配项
我正在使用Jest(^ 24.8.0)进行代码的单元测试,并在package.json中定义了jest配置,但是当我运行npm run test时,它找不到textMatch并显示以下错误:
npm运行测试发现一些错误。请修复它们,然后尝试再次提交。
> jsontocsv@1.0.0 test C:\Users\data-transformation\jsontocsv
> jest "C:\Users\data-transformation\jsontocsv\JsonToCsv.js"
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\data-transformation\jsontocsv
12 files checked.
testMatch: /__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[jt]s?(x) - 1 match
testPathIgnorePatterns: C:\Users\data-transformation\jsontocsv\
ode_modules\, C:\Users\data-transformation\jsontocsv\coverage\ - 12 matches
testRegex: - 0 matches
Pattern: C:\Users\data-transformation\jsontocsv\JsonToCsv.js - 0 matches
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jsontocsv@1.0.0 test: `jest "C:\Users\data-transformation\jsontocsv\JsonToCsv.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jsontocsv@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我的Package.json文件:
"jest": {
"verbose": true,
"moduleFileExtensions": [
"js",
"jsx"
],
"testEnvironment": "node",
"testMatch": [
"/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/coverage/"
],
"collectCoverage": true,
"collectCoverageFrom": [
"*.js?(x)"
],
"coverageDirectory": "<rootDir>/coverage/",
"coverageThreshold": {
"global": {
"branches": 20,
"functions": 30,
"lines": 50,
"statements": 50
}
}
},
"devDependencies": {
"eslint": "^6.0.1",
"eslint-plugin-jest": "^22.13.0",
"husky": "^3.0.0",
"jest": "^24.8.0",
"lint-staged": "^9.2.0",
"prettier": "^1.18.2",
"semistandard": "^13.0.1"
}