Skip to content

Commit

Permalink
fix(vitest-plugin): ensure filename is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencaccia committed Nov 17, 2023
1 parent 5d34938 commit 900f5c4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vitest-plugin/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { Benchmark, Suite } from "vitest";
import { NodeBenchmarkRunner } from "vitest/runners";
import { getBenchFn } from "vitest/suite";

const currentFileName =
typeof __filename === "string"
? __filename
: new URL("runner.mjs", import.meta.url).pathname;

/**
* @deprecated
* TODO: try to use something like `updateTask` from `@vitest/runner` instead to use the output
Expand Down Expand Up @@ -67,7 +72,7 @@ function patchRootSuiteWithFullFilePath(suite: Suite) {

class CodSpeedRunner extends NodeBenchmarkRunner {
async runSuite(suite: Suite): Promise<void> {
logDebug(`PROCESS PID: ${process.pid} in ${__filename}`);
logDebug(`PROCESS PID: ${process.pid} in ${currentFileName}`);
setupCore();

patchRootSuiteWithFullFilePath(suite);
Expand Down

0 comments on commit 900f5c4

Please sign in to comment.