-C flag for generating and reporting test coverage for all files in working directory #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I recently started using expresso, and I specially liked the code coverage output feature. However, I was initially surprised by the
-c
flag behavior. (Instrument the code inlib/
, save inlib-cov/
, then unshift it torequire.paths
)Since my project has code outside of the
lib
folder I would like to report the coverage, I had to manually runnode-jscoverage
and then runexpresso
. I considered making a script to automate this, but I thought that perhaps a new flag on expresso that did the work for me would be a nice addition.What this code does:
When the
-C
(or--cwd-coverage
) flag is supplied, expresso will create a temporary folder and runnode-jscoverage
with the working directory as a source and the temporary folder created as a destination.It then will move the temporary folder with the instrumented code to a hidden
.jscoverage/
directory, nested in the working directory,chdir
into it and run the specified tests there.It's smart enough not to regenerate the instrumented code if no files were changed (it does that by checking the last modified dates), allowing users to run individual test cases without having to wait for
node-jscoverage
to run again.