Skip to content

[Bug]: ClaudeTextGeneration tests are not hermetic on Windows and invoke the real Claude CLI #4507

Description

@mihneaptu

Area

apps/server

Steps to reproduce

  1. On Windows, with a real claude CLI installed and authenticated.
  2. Check out unmodified main at 41a430a8.
  3. Run vp test run apps/server/src/textGeneration/ClaudeTextGeneration.test.ts.

Expected behavior

All 5 tests pass against the stub claude script the fixture writes into a temp bin directory. No network calls, and the run finishes in a couple of seconds.

Actual behavior

All 5 tests fail. The stub is never invoked — the real installed Claude CLI runs instead, so assertions compare fixture strings against live model output. The run takes ~134s because every case makes a real API request.

FAIL  apps/server/src/textGeneration/ClaudeTextGeneration.test.ts
      > falls back when Claude thread title normalization becomes whitespace-only

Expected: "New thread"
Received: "Name Coding Thread Conversation"

 Test Files  1 failed (1)
      Tests  5 failed (5)
   Duration  134.28s

Depending on auth state the failures surface either as live model prose replacing the expected fixture (above), or as live 429 / Not logged in errors.

Cause

Two POSIX-only assumptions in the fixture:

  1. PATH separator. ClaudeTextGeneration.test.ts:99 builds the search path with a literal ::

    process.env.PATH = `${binDir}:${previousPath ?? ""}`;

    Windows uses ;, so binDir never becomes its own PATH entry. path.delimiter would cover both.

  2. Extension-less executable. :27 writes the stub as bin/claude with no extension, and :66 sets 0o755 via fs.chmod, which is a no-op on Windows. Windows resolves executables through PATHEXT, so an extension-less file is skipped even when its directory is on PATH. A claude.cmd shim on Windows would fix this half.

Both need fixing — either alone still leaves the real CLI being picked up.

Side effect

:292 creates .claude-work-test/ under process.cwd() and leaves it behind after the run, so the repo is dirty afterwards.

Impact

Minor bug or occasional failure

Scoped to Windows contributors running this one file, but worth flagging because it fails open rather than closed: instead of erroring on a missing stub, it silently calls the real API and consumes live quota.

Version or commit

main @ 41a430a

Environment

Windows 11, pnpm workspace, Claude Code 2.1.220 installed and authenticated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions