Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karma-coverage-istanbul-reporter

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-coverage-istanbul-reporter - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Change Log

<a name="1.3.0"></a>
# [1.3.0](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/compare/v1.2.1...v1.3.0) (2017-05-26)
### Features
* **thresholds:** allow overriding per file thresholds ([1a894f0](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/commit/1a894f0)), closes [#20](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/issues/20)
* **thresholds:** allow threshold logs not to be emitted as errors ([2de647c](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/commit/2de647c)), closes [#19](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/issues/19)
<a name="1.2.1"></a>

@@ -7,0 +18,0 @@ ## [1.2.1](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/compare/v1.2.0...v1.2.1) (2017-04-30)

23

package.json
{
"name": "karma-coverage-istanbul-reporter",
"version": "1.2.1",
"version": "1.3.0",
"description": "A karma reporter that uses the latest istanbul 1.x APIs (with full sourcemap support) to report coverage.",

@@ -40,3 +40,4 @@ "main": "src/reporter.js",

"dependencies": {
"istanbul-api": "^1.1.8"
"istanbul-api": "^1.1.8",
"minimatch": "^3.0.4"
},

@@ -46,3 +47,3 @@ "devDependencies": {

"@types/mocha": "^2.2.33",
"chai": "^3.5.0",
"chai": "^4.0.0",
"codecov-lite": "^0.1.3",

@@ -53,3 +54,3 @@ "commitizen": "^2.9.6",

"istanbul-instrumenter-loader": "^2.0.0",
"karma": "^1.3.0",
"karma": "^1.7.0",
"karma-mocha": "^1.3.0",

@@ -59,13 +60,13 @@ "karma-phantomjs-launcher": "^1.0.2",

"karma-webpack": "^2.0.1",
"mocha": "^3.2.0",
"nyc": "^10.0.0",
"mocha": "^3.4.2",
"nyc": "^10.3.2",
"rimraf": "^2.5.4",
"standard-version": "^4.0.0",
"ts-loader": "^2.0.0",
"tslint": "^5.1.0",
"ts-loader": "^2.1.0",
"tslint": "^5.3.2",
"tslint-loader": "^3.3.0",
"typescript": "^2.1.0",
"typescript": "^2.3.3",
"validate-commit-msg": "^2.12.1",
"webpack": "^2.2.0",
"xo": "^0.18.0"
"webpack": "^2.6.1",
"xo": "^0.18.2"
},

@@ -72,0 +73,0 @@ "nyc": {

@@ -67,2 +67,3 @@ # karma-coverage-istanbul-reporter

thresholds: {
emitWarning: false, // set to `true` to not fail the test command when thresholds are not met
global: { // thresholds for all files

@@ -78,3 +79,8 @@ statements: 100,

branches: 100,
functions: 100
functions: 100,
overrides: {
'baz/component/**/*.js': {
statements: 98
}
}
}

@@ -81,0 +87,0 @@ }

@@ -85,2 +85,3 @@ 'use strict';

const thresholds = {
emitWarning: false,
global: {

@@ -96,3 +97,4 @@ statements: 0,

branches: 0,
functions: 0
functions: 0,
overrides: {}
}

@@ -107,2 +109,5 @@ };

Object.assign(thresholds.each, userThresholds.each);
if (userThresholds.emitWarning === true) {
thresholds.emitWarning = true;
}
} else {

@@ -113,2 +118,10 @@ Object.assign(thresholds.global, userThresholds);

function logThresholdMessage(message) {
if (thresholds.emitWarning) {
log.warn(message);
} else {
log.error(message);
}
}
let thresholdCheckFailed = false;

@@ -121,8 +134,10 @@

thresholdCheckFailed = true;
log.error(`Coverage for ${type} (${globalSummary[type].pct}%) does not meet global threshold (${thresholds.global[type]}%)`);
logThresholdMessage(`Coverage for ${type} (${globalSummary[type].pct}%) does not meet global threshold (${thresholds.global[type]}%)`);
});
remappedCoverageMap.files().forEach(file => {
const fileThresholds = Object.assign({}, thresholds.each, util.overrideThresholds(file, thresholds.each.overrides, config.basePath));
delete fileThresholds.overrides;
const fileSummary = remappedCoverageMap.fileCoverageFor(file).toSummary().data;
const failedFileTypes = checkThresholds(thresholds.each, fileSummary);
const failedFileTypes = checkThresholds(fileThresholds, fileSummary);

@@ -134,7 +149,7 @@ failedFileTypes.forEach(type => {

}
log.error(`Coverage for ${type} (${fileSummary[type].pct}%) in file ${file} does not meet per file threshold (${thresholds.each[type]}%)`);
logThresholdMessage(`Coverage for ${type} (${fileSummary[type].pct}%) in file ${file} does not meet per file threshold (${fileThresholds[type]}%)`);
});
});
if (thresholdCheckFailed && results) {
if (thresholdCheckFailed && results && !thresholds.emitWarning) {
results.exitCode = 1;

@@ -141,0 +156,0 @@ }

@@ -0,1 +1,6 @@

'use strict';
const path = require('path');
const minimatch = require('minimatch');
function fixWebpackFilePath(filePath) {

@@ -32,3 +37,36 @@ const isWin = process.platform.startsWith('win');

function isAbsolute(file) {
if (path.isAbsolute) {
return path.isAbsolute(file);
}
return path.resolve(file) === path.normalize(file);
}
function normalize(key, basePath) {
// Exclude keys will always be relative, but covObj keys can be absolute or relative
let excludeKey = isAbsolute(key) ? path.relative(basePath, key) : key;
// Also normalize for files that start with `./`, etc.
excludeKey = path.normalize(excludeKey);
return excludeKey;
}
function overrideThresholds(key, overrides, basePath) {
let thresholds = {};
// First match wins
Object.keys(overrides).some(pattern => {
if (minimatch(normalize(key, basePath), pattern, {dot: true})) {
thresholds = overrides[pattern];
return true;
}
return false;
});
return thresholds;
}
module.exports.fixWebpackSourcePaths = fixWebpackSourcePaths;
module.exports.fixWebpackFilePath = fixWebpackFilePath;
module.exports.overrideThresholds = overrideThresholds;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc