Skip to content
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

[Bug]: --watch with coverage produces inconsistent reports #13110

Closed
zebreus opened this issue Aug 9, 2022 · 3 comments
Closed

[Bug]: --watch with coverage produces inconsistent reports #13110

zebreus opened this issue Aug 9, 2022 · 3 comments

Comments

@zebreus
Copy link
Contributor

zebreus commented Aug 9, 2022

Version

28.1.3

Steps to reproduce

  1. Clone https://github.com/Zebreus/jest-watch-bug-repro
  2. Dirty the file alpha.js ( echo " " >> alpha.js )
  3. Run jest --watch --coverage --watchAll
  4. Observe that coverage is reported for all files
  5. Press o
  6. Observe that coverage is only reported for changed files (only alpha.js)
  7. Press a
  8. Expect a coverage report for all files.
  9. Observe that coverage is still only reported for changed files.

This applies to all filters. Once you activate coverage reporting only for changed files, you can't switch back to coverage for all files without restarting jest.

Expected behavior

I have a few ideas about what could be expected, but I think it is quite hard to get this right.

A: Watch reports coverage for all files, unless it is testing only changed files.

If you specifically run a test regex the user is probably also interested in the coverage report for the unchanged files that were involved.

B: Watch reports only coverage for changed files.

This would make coverage reports useful when working on individual files.

C: Guess which files the user is interested in

Maybe figure out which files were involved in the executed tests and only print their coverage. We probably even can figure out which functions were involved and only report their coverage.

Actual behavior

Watch with coverage has no documentation afaik.

If you run jest --watch --coverage it only prints the coverage report for changed files, even if you interactivly specify a custom test regex.

If you run jest --watch --coverage -t something it prints the coverage report for all files.

Once jest starts printing the report only for changed files, there is no way back to printing it for all files.

Additional context

The behaviour of watching only changed files with coverage activated can be quite unexpected and confusing.

I think generating coverage reports without running all tests is a bad idea, because there will be files that only have some tests executed.

Related issues

Environment

System:
    OS: Linux 5.18 NixOS 22.05 (Quokka) 22.05 (Quokka)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz
  Binaries:
    Node: 16.16.0 - /nix/store/vs43ydaw3k0pqa2z3s9mprqaymmbj66p-nodejs-16.16.0/bin/node
    Yarn: 1.22.18 - /nix/store/8fa68i731y9pda2jh52caqc26cqi6h2d-yarn-1.22.18/bin/yarn
    npm: 8.11.0 - /nix/store/vs43ydaw3k0pqa2z3s9mprqaymmbj66p-nodejs-16.16.0/bin/npm
  npmPackages:
    jest: ^28.1.3 => 28.1.3
@github-actions
Copy link

github-actions bot commented Sep 8, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Sep 8, 2022
@github-actions
Copy link

github-actions bot commented Oct 8, 2022

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2022
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

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 Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant