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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

'-o --coverage' should only show the coverage of changed files. #7539

Closed
sai-chai opened this issue Dec 20, 2018 · 8 comments
Closed

'-o --coverage' should only show the coverage of changed files. #7539

sai-chai opened this issue Dec 20, 2018 · 8 comments

Comments

@sai-chai
Copy link

馃殌 Feature Proposal

Combining -o, --onlyChanged, or --watch with --coverage should first run the changed files only, then display coverage for the changed files only, and then rerunning automatically on a save or when Enter/Return is pressed.

Motivation

Jest CLI would work better if it allowed quick limited tests. You should be able to have it running the background as you're writing tests. "--watchAll --coverage" is convenient if you type 'o' or 'f' after the initial run. At that point coverage will only be shown for the files that were tested. However, if you're testing a large enough project, you will end up stuck in that initial run for a while. That's not convenient at all. --watch --coverage doesn't provide that same functionality. After the files are tested, coverage is calculated for the entire project.

Example

Before writing tests, I would start jest --watch --coverage. The program would inform me that there are no changed files. Then I'd write my first test and save it. Jest would automatically run it and show me the remaining coverage on the specific file I was testing only. This would make it easier to continuously test one specific file and see the remaining coverage without pouring over a massive table of values

Pitch

This feature already exists in the platform as part of the flow of --watchAll but it isn't consistent across similar CLI tools. --watch and -o should use --coverage as an alias of --collectCoverageFrom, just like --watchAll does. It's likely a very simple fix and would greatly help users of Jest.

@thymikee
Copy link
Collaborator

I recall we fixed that in master, but can't find the commit. Can you check jest@beta?

@sai-chai
Copy link
Author

6a77ee3#diff-9523ac5aa456fb73fc8008d14432dfff
I found the commit, and it worked the first time around using watchAll, but ever since hitting q to back out of that first run, it no longer works. The only one that's working properly is --changedSince= but of course you need to create a new branch to use that.

@sai-chai
Copy link
Author

I think the problem only appears when comparing against your own branch, even the remote branch you cloned. It works fine when comparing against a parent or sibling.

@thymikee
Copy link
Collaborator

Sounds like a bug, would you mind investigating and maybe send a PR with a fix? Or at least provide a repro :)

@MarcoScabbiolo
Copy link
Contributor

Looks like a duplicate of #6859

@thymikee
Copy link
Collaborator

Let's fix it there, as there's repro provided. Also @sai-chai please confirm it's OK to close this.

@twhoff
Copy link

twhoff commented Apr 9, 2020

Was this fixed?

@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 11, 2021
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

4 participants