Skip to content

Commit cd4648b

Browse files
authored
test: stop default exporting CustomDefaultReporter (#7084)
* test: stop default exporting `CustomDefaultReporter` * fix type default import
1 parent 224a5e0 commit cd4648b

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

test/reporters/custom-default-reporter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ const IGNORE_STACKTRACE: boolean = true;
99

1010
const F_POINTER = "❯";
1111

12+
// NB: If we ever want to use benchmark support, we will need to move the console log overriding to a mixin (different reporter base classes)
13+
1214
/**
1315
* Custom Vitest reporter to strip file name headers and `console.log` stack traces from logging output.
1416
*/
15-
// biome-ignore lint/style/noDefaultExport: Required by Vitest
16-
export default class CustomDefaultReporter extends DefaultReporter {
17+
export class CustomDefaultReporter extends DefaultReporter {
1718
public override onUserConsoleLog(log: UserConsoleLog, taskState?: TestState): void {
1819
// This code is more or less copied verbatim from the `vitest/reporters` bundled source code, with minor tweaks to use
1920
// dependencies we actually _have_ (i.e. chalk) rather than ones we don't (i.e. tinyrainbow).

test/setup/test-end-log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
// biome-ignore lint/correctness/noUnusedImports: Biome can't detect unused imports in preceding doc comments
9-
import type CustomDefaultReporter from "#test/reporters/custom-default-reporter";
9+
import type { CustomDefaultReporter } from "#test/reporters/custom-default-reporter";
1010
import { join, relative } from "path";
1111
import chalk from "chalk";
1212
import type { RunnerTask, RunnerTaskResult, RunnerTestCase } from "vitest";

vitest.config.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import type { UserConfig } from "vite";
1010
import { defineConfig } from "vitest/config";
1111
import { BaseSequencer, type TestSpecification } from "vitest/node";
1212
import { TEST_TIMEOUT } from "./test/constants";
13+
import { CustomDefaultReporter } from "./test/reporters/custom-default-reporter";
1314
import { sharedConfig } from "./vite.config";
1415

15-
const customReporterFile = "./test/reporters/custom-default-reporter.ts" as const;
16-
1716
// biome-ignore lint/style/noDefaultExport: required for vitest
1817
export default defineConfig(async config => {
1918
const viteConfig = await sharedConfig(config);
@@ -22,10 +21,10 @@ export default defineConfig(async config => {
2221
test: {
2322
passWithNoTests: false,
2423
reporters: process.env.MERGE_REPORTS
25-
? ["github-actions", customReporterFile]
24+
? ["github-actions", new CustomDefaultReporter()]
2625
: process.env.GITHUB_ACTIONS
27-
? ["blob", customReporterFile]
28-
: [customReporterFile],
26+
? ["blob", new CustomDefaultReporter()]
27+
: [new CustomDefaultReporter()],
2928
env: {
3029
TZ: "UTC",
3130
},
@@ -57,7 +56,11 @@ export default defineConfig(async config => {
5756
coverage: {
5857
provider: "v8",
5958
reportsDirectory: "coverage",
60-
reporter: process.env.MERGE_REPORTS ? ["text-summary", "json-summary"] : [],
59+
reporter: process.env.MERGE_REPORTS
60+
? ["text-summary", "json-summary"]
61+
: process.env.GITHUB_ACTIONS
62+
? []
63+
: ["text-summary", "html"],
6164
exclude: ["{src,test}/**/*.d.ts"],
6265
include: ["src/**/*.ts", "test/utils/**/*.ts"],
6366
},

0 commit comments

Comments
 (0)