Jestjs jest是否可以在测试运行中包含快照,但不影响代码覆盖率?

Jestjs jest是否可以在测试运行中包含快照,但不影响代码覆盖率?,jestjs,create-react-app,package.json,snapshot,Jestjs,Create React App,Package.json,Snapshot,假设我们有以下文件: - component.tsx - component.test.tsx (1 behavioral test) - component_snapshot.test.tsx (1 snapshot test) 假设component.test.tsx提供了component.tsx的50%代码覆盖率,而component\u snapshot.test.tsx提供了100%的代码覆盖率 是否可以将jest配置为运行这两个测试文件,以查看这两组测试是否都通过,但从总体

假设我们有以下文件:

 - component.tsx
 - component.test.tsx (1 behavioral test)
 - component_snapshot.test.tsx (1 snapshot test)
假设
component.test.tsx
提供了
component.tsx
的50%代码覆盖率,而
component\u snapshot.test.tsx
提供了100%的代码覆盖率

是否可以将jest配置为运行这两个测试文件,以查看这两组测试是否都通过,但从总体测试覆盖率报告中排除快照测试?在此场景中,最终的覆盖率报告将显示
component.tsx
具有50%的测试覆盖率,但有2个测试通过

我可以在单个命令中实现此行为:

  • react scripts test
    ->运行了2个测试,但没有覆盖率报告

  • react scripts test--coverage--testMatch='***/uuu tests++(ts | tsx | js)--testMatch='***/?(*)+(spec | test)。+(ts | tsx | js)--testMatch='**/*快照*”
    ->1测试运行时,快照被排除在外,因此它们不会运行,因此不会报告覆盖率


我希望配置能够运行所有测试(包括快照),但防止快照对覆盖率报告产生影响。

不,它不能。只要有一个脚本同时运行:
“test”:“npm run test:snapshot&&npm run test:cover”