UNPKG

hardhat

Version:

Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.

38 lines • 1.44 kB
import { HardhatError } from "@nomicfoundation/hardhat-errors"; import { getCoverageManager } from "../helpers/accessors.js"; export default async () => ({ onTestRunStart: async (context, id, next) => { await next(context, id); await testRunStart(context, id); }, onTestWorkerDone: async (context, id, next) => { await next(context, id); await testWorkerDone(context, id); }, onTestRunDone: async (context, id, next) => { await next(context, id); await testRunDone(context, id); }, }); export async function testRunStart(context, id) { if (context.globalOptions.coverage === true) { const coverageManager = getCoverageManager(context); // The coverage metadata is collected while building, so a run without a // build (i.e. with --no-compile) has nothing to report against. if (!coverageManager.hasMetadata()) { throw new HardhatError(HardhatError.ERRORS.CORE.COVERAGE.NO_INSTRUMENTED_SOURCES); } await coverageManager.clearData(id); } } export async function testWorkerDone(context, id) { if (context.globalOptions.coverage === true) { await getCoverageManager(context).saveData(id); } } export async function testRunDone(context, id) { if (context.globalOptions.coverage === true) { await getCoverageManager(context).report(id); } } //# sourceMappingURL=test.js.map