Gathering detailed insights and metrics for karma-istanbul-threshold
Gathering detailed insights and metrics for karma-istanbul-threshold
Gathering detailed insights and metrics for karma-istanbul-threshold
Gathering detailed insights and metrics for karma-istanbul-threshold
Karma reporter that checks coverage thresholds with coverage data generated by karma-coverage. Because it reads its data from a json file, it can also handle remapped coverage data provided by karma-remap-istanbul to allow source-map support.
npm install karma-istanbul-threshold
Typescript
Module System
Node Version
NPM Version
59.8
Supply Chain
93.5
Quality
79.9
Maintenance
100
Vulnerability
98.9
License
JavaScript (100%)
Total Downloads
519,554
Last Day
10
Last Week
335
Last Month
1,525
Last Year
25,588
10 Stars
32 Commits
3 Forks
2 Watchers
1 Branches
6 Contributors
Updated on Jun 04, 2024
Latest Version
1.2.3
Package Id
karma-istanbul-threshold@1.2.3
Unpacked Size
11.39 kB
Size
3.69 kB
File Count
4
NPM Version
6.12.0
Node Version
12.13.0
Cumulative downloads
Total Downloads
Last Day
400%
10
Compared to previous day
Last Week
-6.4%
335
Compared to previous week
Last Month
-3.4%
1,525
Compared to previous month
Last Year
-34%
25,588
Compared to previous year
Checks coverage thresholds by using json coverage files generated by Istanbul, karma-coverage or karma-remap-istanbul.
While karma-coverage already allows threshold checks, it unfortunately does not play well with source maps.
karma-remap-istanbul can convert results generated by karma-coverage but does not offer threshold checking.
This plugin fills that gap by using a json file for threshold checking that can be generated by Istanbul or karma-coverage (which internally uses Istanbul). Those json files can be remapped by karma-remap-istanbul to enable source-map support for threshold checking.
The easiest way is to install karma-istanbul-threshold
as a devDependency
,
by running
1npm install karma-istanbul-threshold --save-dev
Add the plugin, reporter and reporter configuration in your karma.conf.js
.
1{ 2 plugins: ['karma-istanbul-threshold'], 3 reporters: ['progress', 'karma-istanbul-threshold'], 4 istanbulThresholdReporter: { 5 src: 'path/to/coverage-report.json', 6 basePath: path.resolve(__dirname, 'path/to/source'), 7 reporters: ['text'], // use 'text' reporter to get text reports like in the screenshot 8 //reporters: ['teamcity'], // use 'teamcity' reporter to generate output for teamcity 9 excludes: [ 10 'some/module/*.ts' // will exclude .ts files in `path/to/source/some/module` 11 ], 12 thresholds: { 13 global: { 14 statements: 90, 15 branches: 90, 16 lines: 70, 17 functions: 90, 18 }, 19 each: { 20 statements: 80, 21 branches: 80, 22 lines: 60, 23 functions: 80, 24 }, 25 }, 26 } 27}
karma-coverage
and karma-remap-istanbul
1{ 2 preprocessors: { 3 'build/**/!(*spec).js': ['coverage'] 4 }, 5 plugins: ['karma-remap-istanbul', 'karma-coverage', 'karma-istanbul-threshold'], 6 reporters: ['progress', 'coverage', 'karma-remap-istanbul', 'istanbul-threshold'], 7 // Creates coverage reports and stores as json 8 coverageReporter: { 9 reporters: [ 10 { type: 'json', dir: 'tmp/coverage', subdir: '.', file: 'coverage-unmapped.json' } 11 ], 12 }, 13 // Creates a source-mapped version of coverage report 14 remapIstanbulReporter: { 15 src: 'tmp/coverage/coverage-unmapped.json', 16 reports: { 17 'json': 'tmp/coverage/coverage-mapped.json' 18 }, 19 }, 20 // Uses source-mapped version to check coverage thresholds 21 istanbulThresholdReporter: { 22 src: 'tmp/coverage/coverage-mapped.json', 23 basePath: path.resolve(__dirname, 'path/to/source'), 24 reporters: ['text'], 25 thresholds: { 26 global: { 27 statements: 90, 28 branches: 90, 29 lines: 70, 30 functions: 90, 31 }, 32 each: { 33 statements: 80, 34 branches: 80, 35 lines: 60, 36 functions: 80, 37 }, 38 }, 39 } 40}
No vulnerabilities found.