Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/e2e/support/live-vitest-invocation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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);
Expand Down Expand Up @@ -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"');
Expand Down
13 changes: 12 additions & 1 deletion tools/e2e/live-vitest-invocation.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down
Loading