Description
🐛 Bug Report
When collectCoverageFrom
is set, then in watch mode with filtering by filename or test name
turned on the filename/test name filtering isn't taken into account for coverage calculation.
The easiest solution seems to be that when in watch mode test filtering is turned on, then collectCoverageFrom
should be ignored.
Thanks to that coverage could be calculated for all required files when running all tests, and when filtering the test it would be obvious that coverage is calculated only for these tests and what they import. Coverage info in watch mode with tests filter is useful, as when working on some tests it can be easily seen if we have certain coverage for the code we work on or not.
To Reproduce
jest --watch --coverage --collectCoverageFrom='src/**/*.js'
Detailed steps:
- Clone https://github.com/duszans/jest-watch-collectCoverageFrom-filtering-repro
yarn
(or use npm)yarn test:watch:withCoverageFrom
- press
p
in the menu - type
add-test
as a pattern - The coverage is calculated for all files based on
collectCoverageFrom
and filter pattern isn't taken into account
Expected behavior
In watch mode with collectCoverageFrom
set the filename/test name filtering is taken into account for coverage calculation.
Link to repl or repo (highly encouraged)
https://github.com/duszans/jest-watch-collectCoverageFrom-filtering-repro
Run npx envinfo --preset jest
Paste the results here:
npx: installed 1 in 4.077s
System:
OS: Linux 4.4 Ubuntu 16.04.3 LTS (Xenial Xerus)
CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 8.9.4 - ~/.nvm/versions/node/v8.9.4/bin/node
Yarn: 1.9.4 - ~/.yarn/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.9.4/bin/npm
npmPackages:
@types/jest: ^23.3.3 => 23.3.3
jest: ^23.6.0 => 23.6.0