Skip to content

Commit e2c4e89

Browse files
jirispilkaclaude
andauthored
chore: Split vitest timeout per suite (unit 30s, integration 120s) (#1071)
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.com/claude-code) https://claude.ai/code/session_016pXZvhEoE6Lz3DpBSL3n1Y --- _Generated by [Claude Code](https://claude.ai/code/session_016pXZvhEoE6Lz3DpBSL3n1Y)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 86c2694 commit e2c4e89

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

vitest.config.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@ export default defineConfig({
55
test: {
66
globals: true,
77
environment: 'node',
8-
include: ['tests/**/*.test.ts'],
9-
testTimeout: 120_000,
8+
projects: [
9+
{
10+
extends: true,
11+
test: {
12+
name: 'unit',
13+
include: ['tests/unit/**/*.test.ts'],
14+
testTimeout: 30_000,
15+
},
16+
},
17+
{
18+
extends: true,
19+
test: {
20+
name: 'integration',
21+
include: ['tests/integration/**/*.test.ts'],
22+
testTimeout: 120_000,
23+
},
24+
},
25+
],
1026
},
1127
});

0 commit comments

Comments
 (0)