Skip to content

test(service): share one Temporal dev server across test files#236

Open
tonyxiao wants to merge 2 commits intov2from
temporal-test-server-sharing
Open

test(service): share one Temporal dev server across test files#236
tonyxiao wants to merge 2 commits intov2from
temporal-test-server-sharing

Conversation

@tonyxiao
Copy link
Copy Markdown
Collaborator

@tonyxiao tonyxiao commented Apr 3, 2026

Summary

  • TestWorkflowEnvironment.createLocal() spawns a real Temporal CLI dev server process. With Vitest's default file parallelism, workflow.test.ts and app.test.ts both called createLocal() concurrently, causing occasional "connection reset by peer" startup races on CI.
  • Fix: start one shared dev server in a new vitest.global-setup.ts (Vitest globalSetup hook) and expose its address via Vitest's provide/inject API.
  • Each test file connects with createFromExistingServer({ address }) instead of createLocal(). teardown() on these envs only closes connections — it does not kill the shared server.
  • Added vitest.d.ts to declare the ProvidedContext type for temporalTestServerAddress.

Test plan

  • pnpm vitest run in apps/service passes all 14 tests (1 skip unchanged)
  • Single Temporal server started per run (visible in logs: one localhost:XXXXX line at startup)
  • pnpm format:check && pnpm lint && pnpm build all clean

🤖 Generated with Claude Code

tonyxiao and others added 2 commits April 3, 2026 09:12
TestWorkflowEnvironment.createLocal() spawns a real Temporal dev server
process. With Vitest's default file parallelism, workflow.test.ts and
app.test.ts both called createLocal() concurrently, causing occasional
"connection reset by peer" startup races on CI.

Fix: start one shared dev server in vitest.global-setup.ts (Vitest
globalSetup hook) and provide its address via Vitest's provide/inject API.
Each test file connects with createFromExistingServer(), which only opens
client connections — teardown() on these envs closes connections but
does not kill the server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Committed-By-Agent: claude
@tonyxiao tonyxiao force-pushed the temporal-test-server-sharing branch from 869cf3a to 0797def Compare April 3, 2026 16:12
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.

1 participant