Socket
Socket
Sign inDemoInstall

karma-coverage-istanbul-reporter

Package Overview
Dependencies
16
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 3.0.0

13

CHANGELOG.md

@@ -1,5 +0,16 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [3.0.0](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/compare/v2.1.1...v3.0.0) (2020-05-01)
### ⚠ BREAKING CHANGES
* node 6 and node 8 are no longer supported. To use this package you must upgrade to node 10 or higher.
### Features
* upgrade to latest istanbul api ([28cbbfb](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/commit/28cbbfb2cf8bd5b9533ceb489cc5047ff3def730))
<a name="2.1.1"></a>

@@ -6,0 +17,0 @@ ## [2.1.1](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/compare/v2.1.0...v2.1.1) (2019-11-21)

52

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

@@ -42,33 +42,36 @@ "funding": {

"dependencies": {
"istanbul-api": "^2.1.6",
"istanbul-lib-coverage": "^3.0.0",
"istanbul-lib-report": "^3.0.0",
"istanbul-lib-source-maps": "^4.0.0",
"istanbul-reports": "^3.0.2",
"minimatch": "^3.0.4"
},
"devDependencies": {
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@commitlint/prompt": "^8.2.0",
"@types/chai": "^4.2.5",
"@types/mocha": "^5.2.7",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@commitlint/prompt": "^8.3.5",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"chai": "^4.2.0",
"codecov": "^3.6.1",
"commitizen": "^4.0.3",
"husky": "^1.3.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^3.1.4",
"karma-mocha": "^1.3.0",
"codecov": "^3.6.5",
"commitizen": "^4.0.5",
"coverage-istanbul-loader": "^3.0.3",
"husky": "^4.2.5",
"karma": "^5.0.4",
"karma-mocha": "^2.0.1",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"prettier": "^1.19.1",
"pretty-quick": "^1.11.1",
"rimraf": "^2.7.1",
"standard-version": "^5.0.2",
"ts-loader": "^5.4.5",
"tslint": "^5.20.1",
"mocha": "^7.1.2",
"nyc": "^15.0.1",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"rimraf": "^3.0.2",
"standard-version": "^7.1.0",
"ts-loader": "^7.0.2",
"tslint": "^6.1.2",
"tslint-loader": "^3.6.0",
"typescript": "^3.7.2",
"webpack": "^4.41.2",
"xo": "^0.24.0"
"typescript": "^3.8.3",
"webpack": "^4.43.0",
"xo": "^0.30.0"
},

@@ -84,2 +87,3 @@ "nyc": {

"space": true,
"prettier": true,
"envs": [

@@ -86,0 +90,0 @@ "node",

@@ -14,3 +14,3 @@ # karma-coverage-istanbul-reporter

This is a reporter only and does not perform the actual instrumentation of your code. Babel users should use the [istanbul babel plugin](https://github.com/istanbuljs/babel-plugin-istanbul) to instrument your code and webpack + typescript users should use the [istanbul-instrumenter-loader](https://github.com/deepsweet/istanbul-instrumenter-loader) and then use this karma reporter to do the actual reporting. See the [test config](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/blob/master/test/karma.conf.js) for an e2e example of how to combine them.
This is a reporter only and does not perform the actual instrumentation of your code. Babel users should use the [istanbul babel plugin](https://github.com/istanbuljs/babel-plugin-istanbul) to instrument your code and webpack + typescript users should use the [coverage-istanbul-loader](https://github.com/JS-DevTools/coverage-istanbul-loader) and then use this karma reporter to do the actual reporting. See the [test config](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/blob/master/test/karma.conf.js) for an e2e example of how to combine them.

@@ -38,5 +38,4 @@ ## Installation

// any of these options are valid: https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-api/lib/config.js#L33-L39
coverageIstanbulReporter: {
// reports can be any that are listed here: https://github.com/istanbuljs/istanbuljs/tree/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib
// reports can be any that are listed here: https://github.com/istanbuljs/istanbuljs/tree/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib
reports: ['html', 'lcovonly', 'text-summary'],

@@ -54,3 +53,3 @@

// Omit files with no statements, no functions and no branches from the report
// Omit files with no statements, no functions and no branches covered from the report
skipFilesWithNoCoverage: true,

@@ -60,3 +59,3 @@

'report-config': {
// all options available at: https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/html/index.js#L135-L137
// all options available at: https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/html/index.js#L257-L261
html: {

@@ -93,9 +92,3 @@ // outputs the report in ./coverage/html

verbose: true, // output config used by istanbul for debugging
// `instrumentation` is used to configure Istanbul API package.
instrumentation: {
// To include `node_modules` code in the report.
'default-excludes': false
}
verbose: true // output config used by istanbul for debugging
}

@@ -108,14 +101,15 @@ });

- [clover](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/clover/index.js#L8-L9)
- [cobertura](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/cobertura/index.js#L9-L10)
- [html](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/html/index.js#L135-L137)
- [json-summary](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/json-summary/index.js#L8)
- [json](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/json/index.js#L8)
- lcov
- [lcovonly](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/lcovonly/index.js#L8)
- [clover](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/clover/index.js#L14-L15)
- [cobertura](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/cobertura/index.js#L16-L17)
- [html-spa](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/html-spa/index.js#L47-L61)
- [html](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/html/index.js#L257-L261)
- [json-summary](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/json-summary/index.js#L12)
- [json](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/json/index.js#L12)
- [lcov](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/lcov/index.js#L13)
- [lcovonly](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/lcovonly/index.js#L11-L12)
- none
- [teamcity](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/teamcity/index.js#L9-L10)
- [text-lcov](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text-lcov/index.js#L9)
- [text-summary](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text-summary/index.js#L9)
- [text](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text/index.js#L159-L160)
- [teamcity](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/teamcity/index.js#L13-L14)
- [text-lcov](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/text-lcov/index.js#L11)
- [text-summary](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/text-summary/index.js#L13)
- [text](https://github.com/istanbuljs/istanbuljs/blob/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib/text/index.js#L231-L237)

@@ -122,0 +116,0 @@ ## Credits

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

const istanbul = require('istanbul-api');
const path = require('path');
const libCoverage = require('istanbul-lib-coverage');
const libSourceMaps = require('istanbul-lib-source-maps');
const libReport = require('istanbul-lib-report');
const libReports = require('istanbul-reports');
const util = require('./util');

@@ -9,3 +13,3 @@

Object.keys(thresholds).forEach(key => {
Object.keys(thresholds).forEach((key) => {
const coverage = summary[key].pct;

@@ -44,3 +48,3 @@ if (coverage < thresholds[key]) {

Object.keys(coverage).forEach(filename => {
Object.keys(coverage).forEach((filename) => {
const fileCoverage = coverage[filename];

@@ -75,3 +79,3 @@ if (fileCoverage.inputSourceMap && coverageConfig.fixWebpackSourcePaths) {

function createReport(browserOrBrowsers, results) {
async function createReport(browserOrBrowsers, results) {
const reportConfigOverride =

@@ -83,21 +87,19 @@ !coverageConfig.combineBrowserReports && coverageConfig.dir

browserOrBrowsers.name
)
),
}
: {};
const reportConfig = istanbul.config.loadObject({
const reportConfig = {
instrumentation: Object.assign({}, coverageConfig.instrumentation),
verbose: coverageConfig.verbose === true,
reporting: Object.assign({}, coverageConfig, reportConfigOverride)
});
const reportTypes = reportConfig.reporting.config.reports;
reporting: Object.assign({}, coverageConfig, reportConfigOverride),
summarizer: coverageConfig.summarizer,
};
const reportTypes = reportConfig.reporting.reports;
const reporter = istanbul.createReporter(reportConfig);
reporter.addAll(reportTypes);
const coverageMap = libCoverage.createCoverageMap();
const sourceMapStore = libSourceMaps.createSourceMapStore();
const coverageMap = istanbul.libCoverage.createCoverageMap();
const sourceMapStore = istanbul.libSourceMaps.createSourceMapStore();
if (coverageConfig.combineBrowserReports) {
browserOrBrowsers.forEach(browser => addCoverage(coverageMap, browser));
browserOrBrowsers.forEach((browser) => addCoverage(coverageMap, browser));
} else {

@@ -107,6 +109,6 @@ addCoverage(coverageMap, browserOrBrowsers);

const {
sourceFinder,
map: remappedCoverageMap
} = sourceMapStore.transformCoverage(coverageMap);
const remappedCoverageMap = await sourceMapStore.transformCoverage(
coverageMap
);
const { sourceFinder } = sourceMapStore;

@@ -116,6 +118,6 @@ if (!coverageConfig.skipFilesWithNoCoverage) {

const fixedFilePaths = {};
remappedCoverageMap.files().forEach(path => {
remappedCoverageMap.files().forEach((path) => {
fixedFilePaths[util.fixPathSeparators(path)] = true;
});
coverageMap.files().forEach(path => {
coverageMap.files().forEach((path) => {
if (!(util.fixPathSeparators(path) in fixedFilePaths)) {

@@ -129,3 +131,3 @@ // Re-add empty coverage record

log.debug('Writing coverage reports:', reportTypes);
reporter.write(remappedCoverageMap, { sourceFinder });
writeReports(reportConfig, remappedCoverageMap, sourceFinder);

@@ -140,3 +142,3 @@ const userThresholds = coverageConfig.thresholds;

branches: 0,
functions: 0
functions: 0,
},

@@ -148,4 +150,4 @@ each: {

functions: 0,
overrides: {}
}
overrides: {},
},
};

@@ -170,3 +172,3 @@

const failedGlobalTypes = checkThresholds(thresholds.global, globalSummary);
failedGlobalTypes.forEach(type => {
failedGlobalTypes.forEach((type) => {
thresholdCheckFailed = true;

@@ -179,3 +181,3 @@ logThresholdMessage(

remappedCoverageMap.files().forEach(file => {
remappedCoverageMap.files().forEach((file) => {
const fileThresholds = Object.assign(

@@ -195,3 +197,3 @@ {},

failedFileTypes.forEach(type => {
failedFileTypes.forEach((type) => {
thresholdCheckFailed = true;

@@ -214,3 +216,21 @@ if (coverageConfig.fixWebpackSourcePaths) {

this.onBrowserComplete = function(browser, result) {
function writeReports(config, coverageMap, sourceFinder) {
const dir = path.resolve(config.reporting.dir);
const contextOptions = {
dir,
watermarks: config.reporting.watermarks || [],
sourceFinder,
coverageMap,
};
const context = libReport.createContext(contextOptions);
const tree = context.getTree(config.summarizer);
config.reporting.reports.forEach((name) => {
const reportConfig = (config.reporting['report-config'] || [])[name];
const report = libReports.create(name, reportConfig);
tree.visit(report, context);
});
}
this.onBrowserComplete = function (browser, result) {
if (result && result.coverage) {

@@ -222,12 +242,11 @@ browserCoverage.set(browser, result.coverage);

const baseReporterOnRunComplete = this.onRunComplete;
this.onRunComplete = function(browsers, results) {
// eslint-disable-next-line prefer-rest-params
baseReporterOnRunComplete.apply(this, arguments);
this.onRunComplete = async function (browsers, results) {
Reflect.apply(baseReporterOnRunComplete, this, arguments);
if (coverageConfig.combineBrowserReports) {
createReport(browsers, results);
await createReport(browsers, results);
} else {
browsers.forEach(browser => {
createReport(browser, results);
});
await Promise.all(
browsers.map((browser) => createReport(browser, results))
);
}

@@ -240,7 +259,7 @@ };

'logger',
'config'
'config',
];
module.exports = {
'reporter:coverage-istanbul': ['type', CoverageIstanbulReporter]
'reporter:coverage-istanbul': ['type', CoverageIstanbulReporter],
};

@@ -5,7 +5,7 @@ const path = require('path');

function fixWebpackFilePath(filePath) {
if (filePath.indexOf('!') !== -1) {
if (filePath.includes('!')) {
filePath = filePath.split('!').pop();
}
if (filePath.indexOf('?') !== -1) {
if (filePath.includes('?')) {
filePath = filePath.split('?')[0];

@@ -47,3 +47,3 @@ }

file: fixPathSeparators(sourceMap.file),
sources: (sourceMap.sources || []).map(source => {
sources: (sourceMap.sources || []).map((source) => {
source = fixWebpackFilePath(source);

@@ -55,3 +55,3 @@ if (sourceRoot && source.startsWith(sourceRoot)) {

return source;
})
}),
});

@@ -87,3 +87,3 @@

// First match wins
Object.keys(overrides).some(pattern => {
Object.keys(overrides).some((pattern) => {
if (minimatch(normalize(key, basePath), pattern, { dot: true })) {

@@ -90,0 +90,0 @@ thresholds = overrides[pattern];

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc