I'm currently getting my test coverage with nyc
and mocha
through something along this:
nyc mocha --recursive $(find src -name '*.spec.ts')
I run this on my CI. However, this runs through all my test files. I would like to verify the test coverage threshold only for the files that are changed in the current branch compared to the master branch.
I have looked around for a solution to this and the closest I could find is to use git diff --name-only
to get the files that were changed. But I'm still not sure how I can use git diff
in combination with nyc
and mocha
to achieve what I want.
How can I verify and check the test coverage meeting its threshold in my CI for only the changed files using nyc
and mocha
?