diff --git a/test/e2e/support/live-vitest-invocation.test.ts b/test/e2e/support/live-vitest-invocation.test.ts index f8e9cb1379..ae51ec2f5a 100644 --- a/test/e2e/support/live-vitest-invocation.test.ts +++ b/test/e2e/support/live-vitest-invocation.test.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { spawnSync } from "node:child_process"; +import path from "node:path"; import { describe, expect, it } from "vitest"; @@ -16,6 +17,9 @@ import { validateLiveTestPath, } from "../../../tools/e2e/live-vitest-invocation.mts"; +const LIVE_VITEST_TOOL = path.resolve("tools/e2e/live-vitest-invocation.mts"); +const TSX = path.resolve("node_modules", ".bin", "tsx"); + describe("validateLiveProject (#6961)", () => { it("accepts the live project and defaults to it", () => { expect(validateLiveProject("e2e-live")).toBe(LIVE_VITEST_PROJECT); @@ -234,12 +238,8 @@ describe("runLiveVitestCommand (#6961)", () => { it.each([ ["missing", []], ["unsupported", ["runx"]], - ])("fails the direct CLI for a %s subcommand", (_label, args) => { - const result = spawnSync( - process.execPath, - ["--experimental-strip-types", "tools/e2e/live-vitest-invocation.mts", ...args], - { encoding: "utf8" }, - ); + ])("fails the workflow CLI for a %s subcommand", (_label, args) => { + const result = spawnSync(TSX, [LIVE_VITEST_TOOL, ...args], { encoding: "utf8" }); expect(result.status).toBe(1); expect(result.stderr).toContain('expected "run"'); diff --git a/tools/e2e/live-vitest-invocation.mts b/tools/e2e/live-vitest-invocation.mts index 8a513c007e..981f22c060 100644 --- a/tools/e2e/live-vitest-invocation.mts +++ b/tools/e2e/live-vitest-invocation.mts @@ -4,7 +4,18 @@ import { spawnSync } from "node:child_process"; import { pathToFileURL } from "node:url"; -import { spawnExitCode } from "../../src/lib/core/process-exit.ts"; +import * as importedProcessExit from "../../src/lib/core/process-exit.ts"; + +// The root TypeScript package is exposed as CJS under the exact `npx tsx` +// workflow execution mode, but as an ESM namespace under Vitest. Normalize +// both representations so the executable and tests share exit handling. +const processExit = ( + "default" in importedProcessExit && importedProcessExit.default + ? importedProcessExit.default + : importedProcessExit +) as typeof import("../../src/lib/core/process-exit.ts"); + +const { spawnExitCode } = processExit; export const LIVE_VITEST_PROJECT = "e2e-live"; export const LIVE_TEST_ROOT = "test/e2e/live/";