Socket
Socket
Sign inDemoInstall

@web/test-runner-core

Package Overview
Dependencies
Maintainers
6
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/test-runner-core - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

6

CHANGELOG.md
# @web/test-runner-core
## 0.6.3
### Patch Changes
- a9603b5: fix merging v8 code coverage
## 0.6.2

@@ -4,0 +10,0 @@

66

dist/coverage/getTestCoverage.js

@@ -11,8 +11,66 @@ "use strict";

];
const locEquals = (a, b) => a.column === b.column && a.line === b.line;
const rangeEquals = (a, b) => locEquals(a.start, b.start) && locEquals(a.end, b.end);
function findBranchKey(branches, branch) {
for (const [key, m] of Object.entries(branches)) {
if (rangeEquals(m.loc, branch.loc)) {
return key;
}
}
}
/**
* Cross references coverage mapping data, looking for missing code branches
* and adding empty entries for them if found. This is necessary because istanbul
* expects code branch data to be equal for all coverage entries, while v8 only
* outputs actual covered code branches.
*
* See https://github.com/istanbuljs/istanbuljs/issues/531 for more.
* @param coverages
*/
function addingMissingCoverageBranches(coverages) {
const branchesPerFile = new Map();
// collect code branches from all code coverage entries
for (const coverage of coverages) {
for (const [filePath, fileCoverage] of Object.entries(coverage)) {
let branches = branchesPerFile.get(filePath);
if (!branches) {
branches = {};
branchesPerFile.set(filePath, branches);
}
for (const branch of Object.values(fileCoverage.branchMap)) {
if (findBranchKey(branches, branch) == null) {
const key = Object.keys(branches).length;
branches[key] = branch;
}
}
}
}
// patch coverage entries to add missing code branches
for (const coverage of coverages) {
for (const [filePath, fileCoverage] of Object.entries(coverage)) {
const branches = branchesPerFile.get(filePath);
const originalBranches = fileCoverage.branchMap;
const originalB = fileCoverage.b;
fileCoverage.branchMap = branches;
fileCoverage.b = {};
for (const [key, mapping] of Object.entries(branches)) {
const originalKey = findBranchKey(originalBranches, mapping);
if (originalKey != null) {
fileCoverage.b[key] = originalB[originalKey];
}
else {
fileCoverage.b[key] = [0];
}
}
}
}
}
function getTestCoverage(sessions, config) {
const coverageMap = istanbul_lib_coverage_1.createCoverageMap();
for (const session of sessions) {
if (session.testCoverage) {
coverageMap.merge(session.testCoverage);
}
const coverages = Array.from(sessions)
.map(s => s.testCoverage)
.filter(c => c);
addingMissingCoverageBranches(coverages);
for (const coverage of coverages) {
coverageMap.merge(coverage);
}

@@ -19,0 +77,0 @@ const summary = coverageMap.getCoverageSummary().data;

2

package.json
{
"name": "@web/test-runner-core",
"version": "0.6.2",
"version": "0.6.3",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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