0.0.2 • Published 2 years ago

@wolox/js-test-coverage-script v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@wolox/js-test-coverage-script

This package is made for retrieve test coverage metrics from lvcov report generated by running test:coverage command, and make a file called code_coverage.json on your root project folder.

Installation

Use npm to install into your project

npm i --also=dev @wolox/js-test-coverage-script

Usage

Add the following into to your project package.json inside the scripts key (example for react projects, modify rescripts for your need, keep these options --watchAll=false --silent --coverageThreshold '{}' --coverageReporters='json-summary'):

"test:generate-coverage-file": "node ./node_modules/@wolox/js-test-coverage-script",
"test:coverage": "rescripts test --env=jsdom --coverage --passWithNoTests --watchAll=false --silent --coverageThreshold '{}' --coverageReporters='json-summary' && npm run test:generate-coverage-file"

The last step is to attach the test:coverage script to husky hook pre-commit (Note this is important because we should retrieve coverage for every commit change, and should be the last step to run):

"pre-commit": "'...your pre-commit config' && npm run test:coverage",

The final result is that your changes into code_coverage.json will be auto-added into your commit, then push as you normally do.

Licence

Copyright 2021 Wolox

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.