Skip to content

chore: Split vitest timeout per suite (unit 30s, integration 120s)#1071

Merged
jirispilka merged 1 commit into
masterfrom
claude/apify-mcp-quick-wins-fysrwa-vitest-timeout
Jul 10, 2026
Merged

chore: Split vitest timeout per suite (unit 30s, integration 120s)#1071
jirispilka merged 1 commit into
masterfrom
claude/apify-mcp-quick-wins-fysrwa-vitest-timeout

Conversation

@jirispilka

Copy link
Copy Markdown
Collaborator

Part of #1066 (checkbox: split the vitest timeout).

What we're solving

vitest.config.ts applied one global testTimeout of 120_000 ms — sized for integration tests, which hit the live Apify API and can legitimately run long — to every test. Unit tests finish in ~7s, so a hung unit test took two minutes to surface instead of failing fast.

How

Replace the flat test block with test.projects:

  • unit project — tests/unit/**, testTimeout: 30_000
  • integration project — tests/integration/**, testTimeout: 120_000

Each uses extends: true to inherit the shared globals/environment. No package.json changes — test:unit and test:integration keep running only their own suites.

Alternatives considered

  • Per-script CLI --testTimeout flag — rejected; the split would live only in package.json and silently fall back to 120s for any invocation not going through that exact script (IDE, watch mode, bare vitest run).
  • A second config file — rejected; two files to keep in sync, duplicated shared settings.

Verification

  • pnpm run test:unit: 70 files / 959 passed / 2 skipped — matches the pre-change baseline, no double-run.
  • Project labels correctly separated: [unit] (959 tests) / [integration] (230 tests).
  • Probe: a unit test sleeping 35s fails with Test timed out in 30000ms; an integration probe passes at 35.5s — confirming the 30s vs 120s split is live per project.
  • Oracle green: type-check clean, lint 0 errors, check:agents passed, format no-op.

🤖 Generated with Claude Code

https://claude.ai/code/session_016pXZvhEoE6Lz3DpBSL3n1Y


Generated by Claude Code

What we're solving: vitest.config.ts applied one global testTimeout of
120_000 ms (sized for integration tests that hit the live Apify API) to
every test. Unit tests run in ~7s, so a hung unit test took two minutes
to fail instead of failing fast.

How: replace the flat test block with test.projects — a `unit` project
(tests/unit/**, 30s timeout) and an `integration` project
(tests/integration/**, 120s timeout), each extends:true to inherit the
shared globals/environment. No package.json changes; test:unit and
test:integration keep running only their own suites.

Alternatives considered: a per-script CLI --testTimeout flag (rejected —
the split would live only in package.json and silently fall back to 120s
for any invocation not going through that script, e.g. IDE or watch mode);
a second config file (rejected — two files to keep in sync).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016pXZvhEoE6Lz3DpBSL3n1Y
@jirispilka jirispilka requested a review from MQ37 July 9, 2026 21:27
@jirispilka jirispilka marked this pull request as ready for review July 9, 2026 21:27
@jirispilka jirispilka requested review from RobertCrupa and removed request for MQ37 July 10, 2026 07:11
@jirispilka jirispilka merged commit e2c4e89 into master Jul 10, 2026
13 checks passed
@jirispilka jirispilka deleted the claude/apify-mcp-quick-wins-fysrwa-vitest-timeout branch July 10, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants