test: speed up vitest launcher startup

This commit is contained in:
Peter Steinberger
2026-04-05 13:01:37 +01:00
parent 6f5ba51f74
commit 074af3f40e
7 changed files with 92 additions and 29 deletions

View File

@@ -22,6 +22,28 @@ describe("resolvePnpmRunner", () => {
});
});
it("prepends node args when launching pnpm through node", () => {
expect(
resolvePnpmRunner({
npmExecPath: "/home/test/.cache/node/corepack/v1/pnpm/10.32.1/bin/pnpm.cjs",
nodeArgs: ["--no-maglev"],
nodeExecPath: "/usr/local/bin/node",
pnpmArgs: ["exec", "vitest", "run"],
platform: "linux",
}),
).toEqual({
command: "/usr/local/bin/node",
args: [
"--no-maglev",
"/home/test/.cache/node/corepack/v1/pnpm/10.32.1/bin/pnpm.cjs",
"exec",
"vitest",
"run",
],
shell: false,
});
});
it("falls back to bare pnpm on non-Windows when npm_execpath is missing", () => {
expect(
resolvePnpmRunner({

View File

@@ -0,0 +1,17 @@
import { describe, expect, it } from "vitest";
import { resolveVitestNodeArgs } from "../../scripts/run-vitest.mjs";
describe("scripts/run-vitest", () => {
it("adds --no-maglev to vitest child processes by default", () => {
expect(resolveVitestNodeArgs({ PATH: "/usr/bin" })).toEqual(["--no-maglev"]);
});
it("allows opting back into Maglev explicitly", () => {
expect(
resolveVitestNodeArgs({
OPENCLAW_VITEST_ENABLE_MAGLEV: "1",
PATH: "/usr/bin",
}),
).toEqual([]);
});
});