hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
35 lines • 1.7 kB
JavaScript
import path from "node:path";
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
import { HardhatRuntimeEnvironmentImplementation } from "../../core/hre.js";
export function getCoveragePath(rootPath) {
return path.join(rootPath, "coverage");
}
/**
* NOTE: The following helpers interact with the global HRE instance only;
* This is OK because:
* - They are intended for the internal use only. They are exposed via the
* internal public API only.
* - We know the HRE has been initialized by the time they are used.
*/
export async function markTestRunStart(id) {
const { default: hre } = await import("../../../index.js");
if (hre.globalOptions.coverage === true) {
assertHardhatInvariant(hre instanceof HardhatRuntimeEnvironmentImplementation, "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation");
await hre._coverage.clearData(id);
}
}
export async function markTestWorkerDone(id) {
const { default: hre } = await import("../../../index.js");
if (hre.globalOptions.coverage === true) {
assertHardhatInvariant(hre instanceof HardhatRuntimeEnvironmentImplementation, "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation");
await hre._coverage.saveData(id);
}
}
export async function markTestRunDone(id) {
const { default: hre } = await import("../../../index.js");
if (hre.globalOptions.coverage === true) {
assertHardhatInvariant(hre instanceof HardhatRuntimeEnvironmentImplementation, "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation");
await hre._coverage.report(id);
}
}
//# sourceMappingURL=helpers.js.map