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

Jest 23 coverage failure for findRelatedTests #6462

Closed
bugzpodder opened this issue Jun 13, 2018 · 7 comments · Fixed by #6736
Closed

Jest 23 coverage failure for findRelatedTests #6462

bugzpodder opened this issue Jun 13, 2018 · 7 comments · Fixed by #6736

Comments

@bugzpodder
Copy link

Jest 23 introduced --findRelatedTests --coverage working together.
I think it doesn't work in an edge case, where if I run
jest --coverage --findRelatedtests src/abc.spec.js
abc.spec.js itself doesn't contribute to coverage count, hence coverage is 0 and the test fails.
jest --coverage --findRelatedtests src/abc.js src/abc.spec.js
This works as expected.
@stipsan

@stipsan
Copy link
Contributor

stipsan commented Jun 13, 2018

Hey!

Can you make a repo that reproduces it?

Thanks 😄

@bugzpodder
Copy link
Author

absolutely, just give me till end of the day, wanted to file this first :)
Thanks for the PR implementing this!

@stipsan
Copy link
Contributor

stipsan commented Jun 13, 2018

Yeah sure, no problem! 😄

@bugzpodder
Copy link
Author

@stipsan
https://github.com/bugzpodder/prime-factorization

Exit code 0:
./node_modules/.bin/jest --coverage
./node_modules/.bin/jest --coverage --findRelatedTests prime-factorization.test.js prime-factorization.js

Exit code 1:
./node_modules/.bin/jest --coverage --findRelatedTests t.js
./node_modules/.bin/jest --coverage --findRelatedTests prime-factorization.test.js
./node_modules/.bin/jest --coverage --findRelatedTests prime-factorization.test.js prime-factorization.js t.js

@stipsan
Copy link
Contributor

stipsan commented Jul 9, 2018

Hey @bugzpodder, sorry for the overdue response!

Thanks for the repro, I looked at it and I think I understand what you’re saying.

Since t.js is negated in collectCoverageFrom it shouldn’t be included when combining —findRelatedTests and —coverage.

I’ll work on a fix this week and ping you back 😄

@stipsan
Copy link
Contributor

stipsan commented Jul 25, 2018

@bugzpodder I finally got around to create a fix, checkout #6736 for details 🙂

aaronabramov pushed a commit that referenced this issue Aug 1, 2018
…m options (#6736)

* add test to reproduce #6462

* fix test

* initial attempt, not happy with it

* take 2, happier with this fix

* better test case

* verify stderr is empty

* Update CHANGELOG.md
@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.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants