类似 Jest, Typescript, ts-jest: Coverage is slightly incorrect -然而,答案适用于旧版本的笑话,其中 mapCoverage 选择是存在的。
mapCoverage
mapCoverage has now been removed 我的印象是ts jest现在应该提供开箱即用的报道。
我遵循了 ts-jest documentation 要安装并运行ts jest:
npm install --save-dev jest typescript ts-jest @types/jest npx ts-jest config:init npx jest --coverage --coverageDirectory='coverage' open coverage/lcov-report/index.ts.html
但是,我可以看到,覆盖率报告生成了错误的地图:
如何使用当前ts笑话获取覆盖地图?
我试着添加 collectCoverage: true 对我的 jest.config.js 这并没有改变输出。
collectCoverage: true
jest.config.js
"compilerOptions": { ... "sourceMap": true,
在你的 tsconfig.json 文件
tsconfig.json
这为我解决了问题。
版本: