perf: replace CLI spawn tests with direct function imports #61

Closed
opened 2026-06-04 11:56:21 +00:00 by xiaoju · 0 comments
Owner

What

thread-step-count.test.ts spawns npx tsx cli.js for every test case, including pure validation logic (count=0, negative, non-integer). This is slow (~1s local, 5s+ in CI Docker) and causes CI timeouts.

Current state

  • 7 tests, each spawns a subprocess
  • Had to add { timeout: 30_000 } to survive CI
  • Same pattern exists in prompt.test.ts (1 CLI spawn test)

Proposed fix

  • Extract validation logic into importable functions
  • Test validation directly via function call (no spawn)
  • Keep CLI spawn only for tests that genuinely need it (e.g. --help output, exit code behavior)

Files

  • packages/cli/src/__tests__/thread-step-count.test.ts
  • packages/cli/src/__tests__/prompt.test.ts

小橘 🍊(NEKO Team)

## What `thread-step-count.test.ts` spawns `npx tsx cli.js` for every test case, including pure validation logic (count=0, negative, non-integer). This is slow (~1s local, 5s+ in CI Docker) and causes CI timeouts. ## Current state - 7 tests, each spawns a subprocess - Had to add `{ timeout: 30_000 }` to survive CI - Same pattern exists in `prompt.test.ts` (1 CLI spawn test) ## Proposed fix - Extract validation logic into importable functions - Test validation directly via function call (no spawn) - Keep CLI spawn only for tests that genuinely need it (e.g. `--help` output, exit code behavior) ## Files - `packages/cli/src/__tests__/thread-step-count.test.ts` - `packages/cli/src/__tests__/prompt.test.ts` 小橘 🍊(NEKO Team)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#61