From 9f7aaa8ad7648cf68c4e60827e3f3d4b219bb4ef Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 5 Apr 2026 13:16:31 +0100 Subject: [PATCH] test: route vitest through node launcher --- scripts/run-vitest.mjs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/run-vitest.mjs b/scripts/run-vitest.mjs index c3a8a795bc1..dc52fc61633 100644 --- a/scripts/run-vitest.mjs +++ b/scripts/run-vitest.mjs @@ -1,6 +1,9 @@ +import { createRequire } from "node:module"; +import path from "node:path"; import { spawnPnpmRunner } from "./pnpm-runner.mjs"; const TRUTHY_ENV_VALUES = new Set(["1", "true", "yes", "on"]); +const require = createRequire(import.meta.url); function isTruthyEnvValue(value) { return TRUTHY_ENV_VALUES.has(value?.trim().toLowerCase() ?? ""); @@ -14,6 +17,11 @@ export function resolveVitestNodeArgs(env = process.env) { return ["--no-maglev"]; } +export function resolveVitestCliEntry() { + const vitestPackageJson = require.resolve("vitest/package.json"); + return path.join(path.dirname(vitestPackageJson), "vitest.mjs"); +} + function main(argv = process.argv.slice(2), env = process.env) { if (argv.length === 0) { console.error("usage: node scripts/run-vitest.mjs "); @@ -21,8 +29,7 @@ function main(argv = process.argv.slice(2), env = process.env) { } const child = spawnPnpmRunner({ - pnpmArgs: ["exec", "vitest", ...argv], - nodeArgs: resolveVitestNodeArgs(env), + pnpmArgs: ["exec", "node", ...resolveVitestNodeArgs(env), resolveVitestCliEntry(), ...argv], env, });