-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Add --coverage option to build scripts for tests #54499
Conversation
|
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've been wanting this officially for a while, thanks!
(c8 hereby runtests-parallel
was an ok thing up until now)
scripts/build/tests.mjs
Outdated
// enable code coverage using 'c8' | ||
let execPath = process.execPath; | ||
if (coverage) { | ||
args.push("exec", "c8", "--clean", execPath); |
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.
Can we dev dep on c8 and run it directly instead of using npm exec
?
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.
It's easier to continue using npm exec
to avoid having to deal with trying to spawn a local package bin and deal with multiple platforms myself, though I can add --prefer-offline
or --offline
to have it prefer the local version.
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.
To clarify, I am both continuing to use npm exec
for convenience and also adding c8
to devDependencies
.
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.
It's easier to continue using
npm exec
to avoid having to deal with trying to spawn a local package bin and deal with multiple platforms myself, though I can add--prefer-offline
or--offline
to have it prefer the local version.
What do you mean by platforms? It should be at node_modules/c8/bin/c8.js
; we execute eslint and mocha using similar methods.
This adds a
--coverage
option to our build scripts for use withruntests
,runtests-parallel
, andruntests-watch
. When--coverage
is specified, tests will be run throughc8
and dump anlcov
format file tocoverage/lcov.info
for use with a code coverage extension for VS Code or other tooling.