【发布时间】:2019-04-17 03:23:06
【问题描述】:
在 create-react-app/react-scripts@2.1.1 项目中,我正在尝试使用 jest-junit 生成覆盖率报告。不幸的是,它失败了:
$ yarn run test --coverage
Failed to write coverage reports:
ERROR: Error: Invalid report format [jest-junit]
STACK: Error: Invalid report format [jest-junit]
at Object.module.exports.create (D:\Users\username\Documents\Project\node_modules\istanbul-api\lib\input-error.js:6:15)
at Reporter.add (D:\Users\username\Documents\Project\node_modules\istanbul-api\lib\reporter.js:51:30)
at D:\Users\username\Documents\Project\node_modules\istanbul-api\lib\reporter.js:62:18
at Array.forEach (<anonymous>)
at Reporter.addAll (D:\Users\username\Documents\Project\node_modules\istanbul-api\lib\reporter.js:61:14)
at D:\Users\username\Documents\Project\node_modules\jest-cli\build\reporters\coverage_reporter.js:180:18
at Generator.next (<anonymous>)
at step (D:\Users\username\Documents\Project\node_modules\jest-cli\build\reporters\coverage_reporter.js:75:30)
at D:\Users\username\Documents\Project\node_modules\jest-cli\build\reporters\coverage_reporter.js:86:15
at process._tickCallback (internal/process/next_tick.js:68:7)
如果我运行yarn run test,我不会遇到任何错误。以下配置块已添加到项目的 package.json 文件中:
{
...
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts",
"!src/**/__stories__/",
"!<rootDir>/node_modules/"
],
"coverageReporters": [
"jest-junit"
]
}
...
}
有人在 create-react-app@2 项目中成功配置了 jest-junit 吗?
【问题讨论】:
-
您的配置似乎与 jest-junit 页面上显示的不匹配,您为什么与此不同?