-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Improve the message when run coverage while there are no tests #6334
Improve the message when run coverage while there are no tests #6334
Conversation
d7b3765
to
12e2f38
Compare
const file = path.resolve(f[0]); | ||
const override = f[1]; | ||
c[file] = new CoverageSummary({ | ||
...covSummary, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Object.assign
@aaronabramov coverage collection is still pretty magical to me, does this change make sense? |
Codecov Report
@@ Coverage Diff @@
## master #6334 +/- ##
==========================================
+ Coverage 63.55% 63.56% +<.01%
==========================================
Files 235 235
Lines 9030 9032 +2
Branches 3 4 +1
==========================================
+ Hits 5739 5741 +2
Misses 3290 3290
Partials 1 1
Continue to review full report at Codecov.
|
@@ -16,6 +16,7 @@ let libSourceMaps; | |||
let CoverageReporter; | |||
let istanbulApi; | |||
|
|||
import {CoverageSummary} from 'istanbul-lib-coverage/lib/file'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it supported to do a deep import like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better way would be to use public createCoverageSummary
api
https://github.com/istanbuljs/istanbuljs/blob/master/packages/istanbul-lib-coverage/index.js#L26-L31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm actually really struggling to understand what's going on here :)
having an e2e test for this would be amazing
@@ -16,6 +16,7 @@ let libSourceMaps; | |||
let CoverageReporter; | |||
let istanbulApi; | |||
|
|||
import {CoverageSummary} from 'istanbul-lib-coverage/lib/file'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better way would be to use public createCoverageSummary
api
https://github.com/istanbuljs/istanbuljs/blob/master/packages/istanbul-lib-coverage/index.js#L26-L31
An e2e test would be great, yeah. Can probably extend https://github.com/facebook/jest/tree/master/e2e/coverage-report to encompass the fix here. Or use it as basis to setup a new dedicated e2e test |
3baf41a
to
6305bfc
Compare
fixes jestjs#6141 Update the coverage reporting so that it still conforms to the documentation but doesn't throw an error when there are no files matching "global" threshold group (maybe because they are already matched with a path or glob). Also make sure that a file is matched against all matching path and glob threshold groups instead of just one.
(instead of the whole module). So that I can use the original createCoverageSummary function to create test data.
6305bfc
to
71b829e
Compare
Yeah, that seems reasonable! 🙂 |
I added snapshots for stderr so that I could test the Jest errors raised for each failed threshold group.
…ge-no-tests-warning
stderr snapshots. Do a replace on the stderr which has a full path to a failed glob threshold file which won't match when the test runs on windows (appveyor)
@aaronabramov might taking a look once again? Test was added :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah! e2e describes what happened much better :)
* upstream/master: (122 commits) fix: don't report promises as open handles (jestjs#6716) support serializing `DocumentFragment` (jestjs#6705) Allow test titles to include array index (jestjs#6414) fix `toContain` suggest to contain equal message (jestjs#6810) fix: testMatch not working with negations (jestjs#6648) Add test cases for jestjs#6744 (jestjs#6772) print stack trace on calls to process.exit (jestjs#6714) Updates SnapshotTesting.md to provide more info. on snapshot scope (jestjs#6735) Mark snapshots as obsolete when moved to an inline snapshot (jestjs#6773) [Docs] Clarified the use of literal values as property matchers in toMatchSnapshot() (jestjs#6807) Update CHANGELOG.md (jestjs#6799) fix changelog entry that is not in 23.4.2 (jestjs#6796) Fix --coverage with --findRelatedTests overwriting collectCoverageFrom options (jestjs#6736) Update testURL default value from about:blank to localhost (jestjs#6792) fix: `matchInlineSnapshot` when prettier dependencies are mocked (jestjs#6776) Fix retryTimes and add e2e regression test (jestjs#6762) Release v23.4.2 Docs/ExpectAPI: Correct docs for `objectContaining` (jestjs#6754) chore(packages/babel-jest) readme (jestjs#6746) docs: noted --coverage aliased by --collectCoverage (jestjs#6741) ...
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Resolves #6141
Summary
I wanted to be able to have a global threshold group (for any new files) even though I have path and glob threshold groups for all the existing files in my project.
At the moment, if you have a global threshold and glob or path matchers for all the files in the coverage data, jest throws an exception:
Jest: Coverage data for global was not found.
I also wanted to be able to have a file be matched by more than one path or glob threshold group. So I can target specific file paths with precise thresholds but still have those files included in a path threshold group targeting the file's directory.
I updated the coverage reporting so that it still conforms to the
documentation but doesn't throw an error when there are no files matching
"global" threshold group (maybe because they are already matched with a path or glob).
I also made sure that a file is matched against all matching path and glob threshold groups instead of just one.
Test plan