@plugjs/cov8
Version:
V8 Coverage Plugin for the PlugJS Build System ==============================================
60 lines (59 loc) • 2.39 kB
TypeScript
import type { Logger } from '@plugjs/plug/logging';
import type { AbsolutePath } from '@plugjs/plug/paths';
import type { CoverageAnalyser } from './analysis';
/**
* A constant indicating that coverage was skipped (is irrelevant, for e.g.
* comment or typescript definition nodes)
*/
export declare const COVERAGE_SKIPPED = -2;
/**
* A constant indicating that coverage was intentionally ignored because of a
* specific "coverage ignore ..." comment
*/
export declare const COVERAGE_IGNORED = -1;
/** Node coverage summary */
export interface NodeCoverageResult {
/** Number of _covered_ nodes (good!) */
coveredNodes: number;
/** Number of nodes with _no coverage_ (bad!) */
missingNodes: number;
/** Number of nodes ignored by comments like `coverage ignore xxx` */
ignoredNodes: number;
/** Total number of nodes (sum of `covered`, `missing` and `ignored`) */
totalNodes: number;
/**
* Percentage of code coverage (covered as a % of total - ignored nodes)
*
* A `null` value for this field indicates that no coverage data was generated
* either because the source was all ignored or skipped (e.g. when using
* `coverage ignore file` or when covering a TS source only with types).
*/
coverage: number | null;
}
/** Per-file coverage result */
export interface CoverageResult {
/** The actual code this coverage is for */
code: string;
/**
* Per _character_ coverage report:
* - `-2`: coverage skipped (comments, typescript declarations, ...)
* - `-1`: coverage ignored (when using `coverage ignore xxx`)
* - `0`: no coverage collected for this character
* - _any number greater than zero_: number of times this was covered
*/
codeCoverage: number[];
/** Node coverage summary */
nodeCoverage: NodeCoverageResult;
}
/** Aggregation of {@link CoverageResult} over all files */
export type CoverageResults = Record<AbsolutePath, CoverageResult>;
/** Our coverage report, per file */
export interface CoverageReport {
results: CoverageResults;
nodes: NodeCoverageResult;
}
/**
* Analyse coverage for the specified source files, using the data from the
* specified coverage files and produce a {@link CoverageReport}.
*/
export declare function coverageReport(analyser: CoverageAnalyser, sourceFiles: AbsolutePath[], log: Logger): Promise<CoverageReport>;