Skip to content

Commit 4be62a4

Browse files
committed
Try using named imports
1 parent 9140a00 commit 4be62a4

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

lib/vitest-reporter/build/coverage-reporter.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ __export(coverage_reporter_exports, {
3434
});
3535
module.exports = __toCommonJS(coverage_reporter_exports);
3636
var import_fs = __toESM(require("fs"), 1);
37-
var import_istanbul_lib_report = __toESM(require("istanbul-lib-report"), 1);
37+
var import_istanbul_lib_report = require("istanbul-lib-report");
3838
function isFull(metrics) {
3939
return metrics.statements.pct === 100 && metrics.branches.pct === 100 && metrics.functions.pct === 100 && metrics.lines.pct === 100;
4040
}
@@ -71,7 +71,7 @@ function getUncoveredLines(node) {
7171
return ranges;
7272
}
7373
var headers = ["Statements", "Branches", "Functions", "Lines"];
74-
var GithubActionsCoverageReporter = class extends import_istanbul_lib_report.default.ReportBase {
74+
var GithubActionsCoverageReporter = class extends import_istanbul_lib_report.ReportBase {
7575
skipEmpty;
7676
skipFull;
7777
results = {};

lib/vitest-reporter/src/__tests__/coverage.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe(CoverageReporter, () => {
2929
}
3030
});
3131

32-
it('doesn\'t open the summary file if GITHUB_STEP_SUMMARY isn\'t defined', ({ reporter }) => {
33-
reporter.onStart({} as any, { watermarks: {} } as any);
34-
expect(fs.createWriteStream).not.toHaveBeenCalled();
32+
it.skipIf(!!process.env.GITHUB_STEP_SUMMARY)('doesn\'t open the summary file if GITHUB_STEP_SUMMARY isn\'t defined', ({ reporter }) => {
33+
reporter.onStart({} as any, { watermarks: {} } as any);
34+
expect(fs.createWriteStream).not.toHaveBeenCalled();
3535
});
3636
});

lib/vitest-reporter/src/__tests__/test-reporter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe(TestReporter, () => {
2626
}
2727
});
2828

29-
it('doesn\'t open the summary file if GITHUB_STEP_SUMMARY isn\'t defined', ({ reporter }) => {
29+
it.skipIf(!!process.env.GITHUB_STEP_SUMMARY)('doesn\'t open the summary file if GITHUB_STEP_SUMMARY isn\'t defined', ({ reporter }) => {
3030
reporter.onInit();
3131
expect(fs.createWriteStream).not.toHaveBeenCalled();
3232
});

lib/vitest-reporter/src/coverage-reporter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import fs from 'fs';
88
import type { CoverageSummary } from 'istanbul-lib-coverage';
9-
import report from 'istanbul-lib-report';
9+
import { ReportBase, type ContextOptions, type ReportNode, type Watermarks } from 'istanbul-lib-report';
1010

1111
/**
1212
* Determines if the coverage summary has full coverage
@@ -23,7 +23,7 @@ function isFull(metrics: CoverageSummary) {
2323
/**
2424
* Determines the uncovered lines
2525
*/
26-
function getUncoveredLines(node: report.ReportNode) {
26+
function getUncoveredLines(node: ReportNode) {
2727
if (node.isSummary()) {
2828
return [];
2929
}
@@ -77,12 +77,12 @@ interface ResultObject {
7777
/**
7878
* A Vitest coverage reporter that writes to the Github Actions summary
7979
*/
80-
export default class GithubActionsCoverageReporter extends report.ReportBase {
80+
export default class GithubActionsCoverageReporter extends ReportBase {
8181
private readonly skipEmpty: boolean;
8282
private readonly skipFull: boolean;
8383
private readonly results: Record<string, ResultObject> = {};
8484
private cw: fs.WriteStream | null = null;
85-
private watermarks: Partial<report.Watermarks> | null = null;
85+
private watermarks: Partial<Watermarks> | null = null;
8686

8787
constructor(opts: any) {
8888
super(opts);
@@ -91,7 +91,7 @@ export default class GithubActionsCoverageReporter extends report.ReportBase {
9191
this.skipFull = Boolean(opts.skipFull);
9292
}
9393

94-
onStart(_node: any, context: report.ContextOptions) {
94+
onStart(_node: any, context: ContextOptions) {
9595
if (!process.env.GITHUB_STEP_SUMMARY) {
9696
console.log('Reporter not being executed in Github Actions environment');
9797
return;
@@ -108,7 +108,7 @@ export default class GithubActionsCoverageReporter extends report.ReportBase {
108108
this.cw.write('</tr></thead><tbody>');
109109
}
110110

111-
onSummary(node: report.ReportNode) {
111+
onSummary(node: ReportNode) {
112112
const nodeName = node.getRelativeName() || 'All Files';
113113
const rawMetrics = node.getCoverageSummary(false);
114114
const isEmpty = rawMetrics.isEmpty();
@@ -129,11 +129,11 @@ export default class GithubActionsCoverageReporter extends report.ReportBase {
129129
};
130130
}
131131

132-
onDetail(node: report.ReportNode) {
132+
onDetail(node: ReportNode) {
133133
return this.onSummary(node);
134134
}
135135

136-
private formatter(pct: number, watermark: keyof report.Watermarks) {
136+
private formatter(pct: number, watermark: keyof Watermarks) {
137137
if (!this.watermarks || this.watermarks[watermark] === undefined) return `<td>${pct}%</td>`;
138138
const [low, high] = this.watermarks[watermark];
139139

0 commit comments

Comments
 (0)