Skip to content

Watch mode filename/test name filtering is not taken into account for coverage calculation with collectCoverageFrom set #7101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
duszans opened this issue Oct 4, 2018 · 3 comments · Fixed by #7611

Comments

@duszans
Copy link

duszans commented Oct 4, 2018

🐛 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:

  1. Clone https://github.com/duszans/jest-watch-collectCoverageFrom-filtering-repro
  2. yarn (or use npm)
  3. yarn test:watch:withCoverageFrom
  4. press p in the menu
  5. type add-test as a pattern
  6. 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

Screenshoots

With collectCoverageFrom

with collectcoveragefrom

Without collectCoverageFrom

without collectcoveragefrom

@rickhanlonii
Copy link
Member

@duszans good report, I think this makes sense and shouldn't be too difficult if you want to take a stab!

duszans pushed a commit to duszans/jest that referenced this issue Oct 16, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@SimenB
Copy link
Member

SimenB commented Feb 7, 2019

I think this was fixed by that PR. Whenever it's released it'd be great to verify

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants