added cli-covarage tool and fixed more tests
This commit is contained in:
parent
b63e58784c
commit
b845a8eade
57 changed files with 11917 additions and 295 deletions
38
tools/coverage-cli/src/reporters/index.ts
Normal file
38
tools/coverage-cli/src/reporters/index.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { TerminalReporter } from './terminal';
|
||||
import { JsonReporter } from './json';
|
||||
import { MarkdownReporter } from './markdown';
|
||||
import { HtmlReporter } from './html';
|
||||
import { HtmlCompactReporter } from './html-compact';
|
||||
import { TextReporter } from './text';
|
||||
import type { CoverageReport, ReporterType } from '../types';
|
||||
|
||||
export class ReporterManager {
|
||||
private reporters = {
|
||||
terminal: new TerminalReporter(),
|
||||
json: new JsonReporter(),
|
||||
markdown: new MarkdownReporter(),
|
||||
html: new HtmlCompactReporter(), // Use compact HTML by default
|
||||
'html-full': new HtmlReporter(), // Keep full HTML as option
|
||||
text: new TextReporter(),
|
||||
};
|
||||
|
||||
async report(coverage: CoverageReport, reporters: ReporterType[], outputDir: string): Promise<void> {
|
||||
for (const reporterType of reporters) {
|
||||
try {
|
||||
const reporter = this.reporters[reporterType];
|
||||
if (!reporter) {
|
||||
console.warn(`Unknown reporter type: ${reporterType}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (reporterType === 'terminal') {
|
||||
reporter.report(coverage);
|
||||
} else {
|
||||
reporter.report(coverage, outputDir);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error running ${reporterType} reporter:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue