-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: jest coverage output #71
Conversation
@@ -122,6 +123,15 @@ if (updateSnapshots) { | |||
config.snapshotResolver = bazelSnapshotResolverPath; | |||
} | |||
|
|||
if (coverageEnabled) { |
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.
Should this be enabled or disabled via a rule attribute?
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.
Does bazel not provide a way to do that already and COVERAGE_OUTPUT_FILE
reflects that? Something like a tag to disable it?
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, I've learned that it's enabled by running bazel coverge
and ensuring this target is instrumented in the --instrumentation_filter
. Can be checked with ctx.coverage_instrumented()
.
config.collectCoverage = true; | ||
config.coverageDirectory = path.dirname(process.env.COVERAGE_OUTPUT_FILE); | ||
config.coverageReporters = [ | ||
"text", | ||
["lcovonly", { file: path.basename(process.env.COVERAGE_OUTPUT_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.
Should I take what they already have in their jest config into account, or always overwrite?
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.
Could probably overwrite to start, wait to see if anyone would want to customize it more?
@thesayyn knows this stuff well and could give a good review here |
set -o errexit -o nounset -o pipefail | ||
|
||
# Case 6: generate a coverage report | ||
bazel coverage //jest/tests:case6 --instrument_test_targets |
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.
--instrument_test_targets
doesn't seem to have any effect on the COVERAGE_OUTPUT_FILE
var existing. I'm not not too sure what purpose it should serve here or if it's even needed.
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.
this flag only affects process.env.COVERAGE_MANIFEST
. It'll only add more items to the coverage manifest.
A few missing pieces;
I am not sure which files jest decides to generate the coverage report for but that should be limited to what described in |
Switched to DRAFT while Derek on vacation. This will get finished up in January. |
12ac706
to
0ac4b49
Compare
Thanks for the feedback @thesayyn. This is ready for review again. |
0ac4b49
to
926acfe
Compare
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.
🦖
#34
First time doing anything coverage-related in Bazel, so I may be doing something weird.