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

Coverage is confusing in watch mode #2256

Closed
gaearon opened this issue Dec 8, 2016 · 6 comments · Fixed by #5601
Closed

Coverage is confusing in watch mode #2256

gaearon opened this issue Dec 8, 2016 · 6 comments · Fixed by #5601

Comments

@gaearon
Copy link
Contributor

gaearon commented Dec 8, 2016

These two screens say it all:

screen shot 2016-12-08 at 15 22 42

screen shot 2016-12-08 at 15 22 57

It's the same code without any changes. It's just that the first time no tests ran (because none changed since last commit), and thus coverage reported 0%.

Should we disable the "lazy run" logic when coverage is requested?

@cpojer
Copy link
Member

cpojer commented Dec 8, 2016

This is why I repeatedly said that using coverage in watch mode isn't very useful. I think it would be smarter to allow coverage only when you run all tests in this mode but not sure how to best signal it.

@jwbay
Copy link
Contributor

jwbay commented Dec 11, 2016

I definitely agree the behavior is initially confusing, but I think coverage + watch mode does enable a pretty nice workflow after you realize it's only reporting on what ran last. I keep thinking how nice it would be to pair Jest's watch mode with some kind of coverage server that could reload the html report when it changes. No more alt tab and refresh, just write tests and watch the red code change to green code.

One thing that probably should be disabled for coverage + watch is the coverage threshold error though.

@kellyjandrews
Copy link

Is it possible to display only the coverage of the changed/affected files? That would be really great to see as I'm writing tests. Unsure how possible that is.

@moaazsidat
Copy link

Similar question as above, would it be possible to perhaps configure a parameter that controls/overrides collectCoverageFrom so that you can generate coverage for only part of an app?

@kohlmannj
Copy link

@moaazsidat Tangentially, today I discovered that, in order to see coverage information when watching a pattern, I had to provide a similar pattern again via --collectCoverageFrom=[similar pattern].

It'd be great if there were some option to show coverage just for the watched patterns!

@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
@SimenB SimenB removed the Question label Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants