Wei*_*a25 5 javascript typescript reactjs jestjs ts-jest
我一直在使用 jest --coverage 来计算我的代码的覆盖率。我coverageThreshold在 jest.config.js 中添加了一个,但这仅检查整个代码库/文件夹覆盖范围。
我也尝试过开玩笑-o(--onlyChanged),但这会生成整个文件的覆盖百分比,使得实际的新行覆盖率看起来比实际情况要高。
有没有办法仅检查新行(未更改行)jest --coverage的覆盖率?
示例:整个文件覆盖示例,将超过 95% 的全局阈值。一个新的 if 语句行,没有编写测试:
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 96.15 | 95.83 | 100 | 95.83 |
changeFile.tsx| 96.15 | 95.83 | 100 | 95.83 | 119
--------------|---------|----------|---------|---------|-------------------
EXAMPLE: as supposed to NEW line coverage example, will fail if global threshold is 95%, fails due to one of the lines not covered.
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered New Line #s
--------------|---------|----------|---------|---------|-------------------
changeFile.tsx| 50.00 | 100 | 100 | 100 | 1/2
--------------|---------|----------|---------|---------|-------------------
Run Code Online (Sandbox Code Playgroud)
尝试过:
开玩笑-o(--onlyChanged),--lastCommit,--changedSince
但他们只计算整个更改文件的覆盖百分比
如果有其他覆盖工具可以完成此任务,我们将不胜感激:)
| 归档时间: |
|
| 查看次数: |
357 次 |
| 最近记录: |