Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 21 additions & 1 deletion packages/core/src/types/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ type ReportWithOptions<Name extends keyof ReportOptions = keyof ReportOptions> =
? [Name, Partial<ReportOptions[Name]>]
: [Name, Record<string, unknown>];

/** Custom reporter configuration for non-istanbul reporters */
type CustomReporter = string | [string, Record<string, unknown>];

/** Union type for all supported reporter types */
type SupportedReporter =
| keyof ReportOptions
| ReportWithOptions
| ReportBase
| CustomReporter;

export type CoverageThreshold = {
/** Threshold for statements */
statements?: number;
Expand Down Expand Up @@ -82,9 +92,19 @@ export type CoverageOptions = {

/**
* The reporters to use for coverage collection.
* Supports built-in istanbul reporters and custom reporters (e.g., '@canyonjs/report-html').
* @default ['text', 'html', 'clover', 'json']
* @example
* // Built-in reporters
* reporters: ['text', 'html', ['json', { file: 'coverage.json' }]]
*
* // Custom reporters
* reporters: ['@canyonjs/report-html', ['custom-reporter', { outputDir: './reports' }]]
*
* // Mixed usage
* reporters: ['text', '@canyonjs/report-html', ['html', { subdir: 'html-report' }]]
*/
reporters?: (keyof ReportOptions | ReportWithOptions | ReportBase)[];
reporters?: SupportedReporter[];

/**
* The directory to store coverage reports.
Expand Down
6 changes: 5 additions & 1 deletion packages/coverage-istanbul/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ export class CoverageProvider implements RstestCoverageProvider {
const [reporterName, reporterOptions] = Array.isArray(reporter)
? reporter
: [reporter, {}];
const report = reports.create(reporterName, reporterOptions);
const report = reports.create(
reporterName as Parameters<typeof reports.create>[0],
reporterOptions,
);
//NOTE: https://github.com/vitest-dev/vitest/blob/41a111c35b6605dbe8a536a6e03b35e9bc0ce770/packages/coverage-istanbul/src/provider.ts#L145
report.execute(context);
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ browserslistrc
bundleless
bytedance
caniuse
canyonjs
CEHQ
chunkhash
Chunktmp
Expand Down
Loading