Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
731d409
mvp
ChristopherDedominici Oct 8, 2025
4088b56
istanbul libCoverage: copy original js file in root assets folder
ChristopherDedominici Oct 13, 2025
e3d52e3
libReport
ChristopherDedominici Oct 16, 2025
4dae722
report
ChristopherDedominici Oct 16, 2025
d002919
remove dependencies from istanbul in coverage-manager
ChristopherDedominici Oct 16, 2025
95f8d9a
add 'node:' to imports
ChristopherDedominici Oct 16, 2025
f3e276f
replace import to istanbul with internal assets
ChristopherDedominici Oct 17, 2025
c77eb8d
remove unused library
ChristopherDedominici Oct 17, 2025
7771d9f
replace html escape package
ChristopherDedominici Oct 17, 2025
029bc26
replace make-dir with fs/promises
ChristopherDedominici Oct 17, 2025
9be67d5
remove dependencies from istanbul npm packages
ChristopherDedominici Oct 17, 2025
3a55628
base package
ChristopherDedominici Oct 17, 2025
cc5cb6a
move js istanbul libs in the new package
ChristopherDedominici Oct 17, 2025
1856995
add postbuild script and re-organize coverage-manager
ChristopherDedominici Oct 23, 2025
e646399
exclude js, cjs, css, png from the gitignore
ChristopherDedominici Oct 27, 2025
3047483
rename to hardhat-vendored
ChristopherDedominici Oct 27, 2025
c8ea036
exclude from gitignore
ChristopherDedominici Oct 27, 2025
39ce891
delete test file
ChristopherDedominici Oct 27, 2025
c6f1e72
remove dist folder
ChristopherDedominici Oct 27, 2025
f78a224
fix package name and imports
ChristopherDedominici Oct 27, 2025
b28430a
rename folder to avoid gitignore
ChristopherDedominici Oct 27, 2025
8c92ef9
fix copy-assets
ChristopherDedominici Oct 27, 2025
022c6ae
fix exports after changing folder name
ChristopherDedominici Oct 27, 2025
a50b3b8
show colored lines in coverage report
ChristopherDedominici Oct 27, 2025
0b89710
update tsconfig in new vendored package
ChristopherDedominici Oct 28, 2025
50f3b4c
minor fixes
ChristopherDedominici Oct 28, 2025
f3591e7
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici Oct 28, 2025
d0fba8e
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici Nov 3, 2025
3602408
lint:fix
ChristopherDedominici Nov 3, 2025
006f834
Create gorgeous-swans-try.md
ChristopherDedominici Nov 3, 2025
f771d34
ignore spelling in vendored package src code
ChristopherDedominici Nov 3, 2025
7724608
Merge branch 'html-coverage' of github.com:NomicFoundation/hardhat in…
ChristopherDedominici Nov 3, 2025
9dde2ee
remove dependency from @nomicfoundation/hardhat-node-test-reporter
ChristopherDedominici Nov 3, 2025
7542cdc
add reference to test reporter
ChristopherDedominici Nov 3, 2025
8ed50de
Merge branch 'html-coverage' of github.com:NomicFoundation/hardhat in…
ChristopherDedominici Nov 3, 2025
f264363
add hardhat-node-test-reporter in package.json
ChristopherDedominici Nov 3, 2025
b26e193
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici Nov 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions v-next/hardhat/assets/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import libCoverage from "./lib-coverage/index.cjs";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a "bridge" to expose the common js code into ESM js code, so that the ts file can then import it

export default libCoverage;
64 changes: 64 additions & 0 deletions v-next/hardhat/assets/lib-coverage/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2012-2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
"use strict";

/**
* istanbul-lib-coverage exports an API that allows you to create and manipulate
* file coverage, coverage maps (a set of file coverage objects) and summary
* coverage objects. File coverage for the same file can be merged as can
* entire coverage maps.
*
* @module Exports
*/
const { FileCoverage } = require("./lib/file-coverage.cjs");
const { CoverageMap } = require("./lib/coverage-map.cjs");
const { CoverageSummary } = require("./lib/coverage-summary.cjs");

module.exports = {
/**
* creates a coverage summary object
* @param {Object} obj an argument with the same semantics
* as the one passed to the `CoverageSummary` constructor
* @returns {CoverageSummary}
*/
createCoverageSummary(obj) {
if (obj && obj instanceof CoverageSummary) {
return obj;
}
return new CoverageSummary(obj);
},
/**
* creates a CoverageMap object
* @param {Object} obj optional - an argument with the same semantics
* as the one passed to the CoverageMap constructor.
* @returns {CoverageMap}
*/
createCoverageMap(obj) {
if (obj && obj instanceof CoverageMap) {
return obj;
}
return new CoverageMap(obj);
},
/**
* creates a FileCoverage object
* @param {Object} obj optional - an argument with the same semantics
* as the one passed to the FileCoverage constructor.
* @returns {FileCoverage}
*/
createFileCoverage(obj) {
if (obj && obj instanceof FileCoverage) {
return obj;
}
return new FileCoverage(obj);
},
};

/** classes exported for reuse */
module.exports.classes = {
/**
* the file coverage constructor
*/
FileCoverage,
};
134 changes: 134 additions & 0 deletions v-next/hardhat/assets/lib-coverage/lib/coverage-map.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
Copyright 2012-2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
"use strict";

const { FileCoverage } = require("./file-coverage.cjs");
const { CoverageSummary } = require("./coverage-summary.cjs");

function maybeConstruct(obj, klass) {
if (obj instanceof klass) {
return obj;
}

return new klass(obj);
}

function loadMap(source) {
const data = Object.create(null);
if (!source) {
return data;
}

Object.entries(source).forEach(([k, cov]) => {
data[k] = maybeConstruct(cov, FileCoverage);
});

return data;
}

/** CoverageMap is a map of `FileCoverage` objects keyed by file paths. */
class CoverageMap {
/**
* @constructor
* @param {Object} [obj=undefined] obj A coverage map from which to initialize this
* map's contents. This can be the raw global coverage object.
*/
constructor(obj) {
if (obj instanceof CoverageMap) {
this.data = obj.data;
} else {
this.data = loadMap(obj);
}
}

/**
* merges a second coverage map into this one
* @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged
* correctly for the same files and additional file coverage keys are created
* as needed.
*/
merge(obj) {
const other = maybeConstruct(obj, CoverageMap);
Object.values(other.data).forEach((fc) => {
this.addFileCoverage(fc);
});
}

/**
* filter the coveragemap based on the callback provided
* @param {Function (filename)} callback - Returns true if the path
* should be included in the coveragemap. False if it should be
* removed.
*/
filter(callback) {
Object.keys(this.data).forEach((k) => {
if (!callback(k)) {
delete this.data[k];
}
});
}

/**
* returns a JSON-serializable POJO for this coverage map
* @returns {Object}
*/
toJSON() {
return this.data;
}

/**
* returns an array for file paths for which this map has coverage
* @returns {Array{string}} - array of files
*/
files() {
return Object.keys(this.data);
}

/**
* returns the file coverage for the specified file.
* @param {String} file
* @returns {FileCoverage}
*/
fileCoverageFor(file) {
const fc = this.data[file];
if (!fc) {
throw new Error(`No file coverage available for: ${file}`);
}
return fc;
}

/**
* adds a file coverage object to this map. If the path for the object,
* already exists in the map, it is merged with the existing coverage
* otherwise a new key is added to the map.
* @param {FileCoverage} fc the file coverage to add
*/
addFileCoverage(fc) {
const cov = new FileCoverage(fc);
const { path } = cov;
if (this.data[path]) {
this.data[path].merge(cov);
} else {
this.data[path] = cov;
}
}

/**
* returns the coverage summary for all the file coverage objects in this map.
* @returns {CoverageSummary}
*/
getCoverageSummary() {
const ret = new CoverageSummary();
Object.values(this.data).forEach((fc) => {
ret.merge(fc.toSummary());
});

return ret;
}
}

module.exports = {
CoverageMap,
};
112 changes: 112 additions & 0 deletions v-next/hardhat/assets/lib-coverage/lib/coverage-summary.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
Copyright 2012-2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
"use strict";

const percent = require("./percent.cjs");
const dataProperties = require("./data-properties.cjs");

function blankSummary() {
const empty = () => ({
total: 0,
covered: 0,
skipped: 0,
pct: "Unknown",
});

return {
lines: empty(),
statements: empty(),
functions: empty(),
branches: empty(),
branchesTrue: empty(),
};
}

// asserts that a data object "looks like" a summary coverage object
function assertValidSummary(obj) {
const valid =
obj && obj.lines && obj.statements && obj.functions && obj.branches;
if (!valid) {
throw new Error(
"Invalid summary coverage object, missing keys, found:" +
Object.keys(obj).join(","),
);
}
}

/**
* CoverageSummary provides a summary of code coverage . It exposes 4 properties,
* `lines`, `statements`, `branches`, and `functions`. Each of these properties
* is an object that has 4 keys `total`, `covered`, `skipped` and `pct`.
* `pct` is a percentage number (0-100).
*/
class CoverageSummary {
/**
* @constructor
* @param {Object|CoverageSummary} [obj=undefined] an optional data object or
* another coverage summary to initialize this object with.
*/
constructor(obj) {
if (!obj) {
this.data = blankSummary();
} else if (obj instanceof CoverageSummary) {
this.data = obj.data;
} else {
this.data = obj;
}
assertValidSummary(this.data);
}

/**
* merges a second summary coverage object into this one
* @param {CoverageSummary} obj - another coverage summary object
*/
merge(obj) {
const keys = [
"lines",
"statements",
"branches",
"functions",
"branchesTrue",
];
keys.forEach((key) => {
if (obj[key]) {
this[key].total += obj[key].total;
this[key].covered += obj[key].covered;
this[key].skipped += obj[key].skipped;
this[key].pct = percent(this[key].covered, this[key].total);
}
});

return this;
}

/**
* returns a POJO that is JSON serializable. May be used to get the raw
* summary object.
*/
toJSON() {
return this.data;
}

/**
* return true if summary has no lines of code
*/
isEmpty() {
return this.lines.total === 0;
}
}

dataProperties(CoverageSummary, [
"lines",
"statements",
"functions",
"branches",
"branchesTrue",
]);

module.exports = {
CoverageSummary,
};
12 changes: 12 additions & 0 deletions v-next/hardhat/assets/lib-coverage/lib/data-properties.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

module.exports = function dataProperties(klass, properties) {
properties.forEach((p) => {
Object.defineProperty(klass.prototype, p, {
enumerable: true,
get() {
return this.data[p];
},
});
});
};
Loading
Loading