Skip to content

Commit 900f5c4

Browse files
committed
fix(vitest-plugin): ensure filename is defined
1 parent 5d34938 commit 900f5c4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/vitest-plugin/src/runner.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { Benchmark, Suite } from "vitest";
1111
import { NodeBenchmarkRunner } from "vitest/runners";
1212
import { getBenchFn } from "vitest/suite";
1313

14+
const currentFileName =
15+
typeof __filename === "string"
16+
? __filename
17+
: new URL("runner.mjs", import.meta.url).pathname;
18+
1419
/**
1520
* @deprecated
1621
* TODO: try to use something like `updateTask` from `@vitest/runner` instead to use the output
@@ -67,7 +72,7 @@ function patchRootSuiteWithFullFilePath(suite: Suite) {
6772

6873
class CodSpeedRunner extends NodeBenchmarkRunner {
6974
async runSuite(suite: Suite): Promise<void> {
70-
logDebug(`PROCESS PID: ${process.pid} in ${__filename}`);
75+
logDebug(`PROCESS PID: ${process.pid} in ${currentFileName}`);
7176
setupCore();
7277

7378
patchRootSuiteWithFullFilePath(suite);

0 commit comments

Comments
 (0)