You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CI test runs are intermittently failing with Exceeded timeout of 15000 ms for a hook (e.g. PR #69, which passed only on re-run with no code changes).
The failures are not assertion failures — they are the testcontainers Postgres beforeAll hook timing out.
Root cause
tests/setup.ts is registered via setupFilesAfterEnv in jest.config.ts, so it runs once per test file. With 6 test suites, that means:
6 separate Postgres containers are started and stopped per CI run
each runs prisma db push in its beforeAll
each must complete within the global testTimeout: 15000 (15s)
On CI runners (slower IO, image pull, cold start) the per-suite container startup + prisma db push regularly exceeds 15s, causing the whole suite's tests to fail. Locally it's non-deterministic (one run: 2 suites fail on the hook; next run: fully green).
Proposed fix (option 1: single container + per-suite schema)
Start one Postgres container for the whole test run and isolate suites by Postgres schema:
Move container startup into a Jest globalSetup (and teardown into globalTeardown) so the container is created/destroyed once per run.
Give each test file its own Postgres schema (e.g. derived from the worker id / file name) and set search_path per suite, or use a separate database per worker.
Run prisma db push once against the shared instance, or once per schema as needed.
Benefits: container started once (faster, far fewer cold-start timeouts) while preserving test isolation between suites.
Alternatives considered
Bump the hook timeout (beforeAll(async () => {…}, 60000)) — lowest effort, keeps per-suite isolation, but keeps the 6x container churn (slow) and only masks the race.
Shared container + truncate/rollback between tests — works but more bookkeeping; risk of cross-suite state leakage if not careful with parallel workers.
Acceptance criteria
Single Postgres container per test run (not per suite)
Test isolation preserved (no cross-suite state leakage)
CI test step is reliably green across repeated runs
Test suite wall-clock time does not regress (ideally improves)
Problem
CI test runs are intermittently failing with
Exceeded timeout of 15000 ms for a hook(e.g. PR #69, which passed only on re-run with no code changes).The failures are not assertion failures — they are the testcontainers Postgres
beforeAllhook timing out.Root cause
tests/setup.tsis registered viasetupFilesAfterEnvinjest.config.ts, so it runs once per test file. With 6 test suites, that means:prisma db pushin itsbeforeAlltestTimeout: 15000(15s)On CI runners (slower IO, image pull, cold start) the per-suite container startup +
prisma db pushregularly exceeds 15s, causing the whole suite's tests to fail. Locally it's non-deterministic (one run: 2 suites fail on the hook; next run: fully green).Proposed fix (option 1: single container + per-suite schema)
Start one Postgres container for the whole test run and isolate suites by Postgres schema:
globalSetup(and teardown intoglobalTeardown) so the container is created/destroyed once per run.search_pathper suite, or use a separate database per worker.prisma db pushonce against the shared instance, or once per schema as needed.Benefits: container started once (faster, far fewer cold-start timeouts) while preserving test isolation between suites.
Alternatives considered
beforeAll(async () => {…}, 60000)) — lowest effort, keeps per-suite isolation, but keeps the 6x container churn (slow) and only masks the race.Acceptance criteria
References
tests/setup.tsjest.config.ts(setupFilesAfterEnv,testTimeout: 15000)