I'm using lint-staged with Jest testing framework to test only changed files from last commit as described in this blog.
My configuration is as below:
"src/**/*.{ts}": [
"prettier --write",
"tslint --fix --project .",
"jest --bail --findRelatedTests",
"git add"
]
I also want to generate coverage-report for only changed files. To do this, I have to put list of changed files in multiple places.
jest --bail --findRelatedTests <spaceSeparatedListOfSourceFiles> --collectCoverageFrom=<glob>
Using lint-staged, how can I limit both test and coverage-report only for changed files?
I didn't know about lint-staged
. I'll give it a try. I looked for this a while ago.
Have you tried?
"jest --bail --coverage --findRelatedTests",
Jest docs say that findRelatedTests
can be used together with --coverage to include a test coverage for the source files, no duplicate --collectCoverageFrom arguments needed.
Should work but I haven't tried.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With