TSCOV - Check the type coverage of any TypeScript project with this easy npm package
Quick start
Globally
First globally install tscov
by running the following in the command line.
npm i tscov -g cd <your-repo-location> # To run the coverage of the types. tscov
Project
Go to your local project in the command line.
Then install tscov
as devDependency by running:
npm i tscov --save-dev
And set tscov up by adding an extra npm script in your package.json
like this:
"scripts": ,
Then you could run this with:
npm run tscov
How to use
You can use the following commands in the command line or in a project as npm script:
# Show max reachable coverage and covered/uncovered types (default 90% minimal coverage) tscov # Define your minimum wanted coverage % by replacing `NUMBER` (0-100) with `95` for example tscov -m NUMBERtscov --min-coverage NUMBER # Show all uncovered types tscov -dtscov --details # Test specific folder tscov -p PATH_TO_FOLDER/FOLDERNAMEtscov --project PATH_TO_FOLDER/FOLDERNAME # Testing specific files tscov -p PATH_TO_FOLDER/FOLDERNAME -f FILENAME.tstscov --project PATH_TO_FOLDER/FOLDERNAME --file FILENAME.ts # Start debugging tscov --debug # Show version tscov -vtscov --version # Show all available options tscov -htscov --help
Example output
Example by running this command: tscov --min-coverage=95
.
_____ ____ ____ ___ __ __ |_ _| / ___| / ___| / _ \ \ \ / / | | \___ \ | | | | | | \ \ / / | | ___) | | |___ | |_| | \ V / |_| |____/ \____| \___/ \_/ The TypeScript CLI to calculate type coverage ----------------- coverage ------------------3337 - max reachable type coverage3287 - types covered50 - types uncovered 98.50% - coverage percentageYou can run "tscov --details" to show all uncovered types.
Contributing
Want to file a bug, contribute some code, or improve documentation? Feel free to place an issue.
First fork this project.
git clone <your-forked-repo>npm install git checkout -b my-fix# fix some code... git commit -m "added this feature"git push origin my-fix
Lastly, open a pull request on Github.
The following npm script are available
npm start
- create build, install globally and run tscovnpm run build
- create buildnpm run global
- install globally and run tscovnpm run link-upstream
- add remotenpm run sync
- fetch, checkout, merge and pushnpm run reset
- removes node modules, package-lock.json, lib and re-installs everything.