archal/vitest when you already have a Vitest project and want hosted twins inside your integration tests.
Linear and Ramp twins are available via archal run and archal twin start but don’t yet have route-mode manifests for Vitest.
Install
ARCHAL_TOKEN instead of running archal login.
Add Archal to your existing vitest.config.ts
If your project already has a vitest.config.ts, wrap the value of test: with withArchal. It’s a merge helper — every field you already had (coverage, alias, globalSetup, poolOptions, custom reporters, etc.) is preserved, and Archal composes its setup file, reporter, and session env on top.
{} as the first argument: withArchal({}, { services: { ... } }).
Or add a separate project in vitest.workspace.ts
For monorepos or when only a subset of tests should hit twins, use a workspace:
include glob will provision hosted twins; the rest run as normal Vitest.
Write a test
Your test code uses normal SDK clients or direct HTTP calls. Route mode intercepts the HTTP traffic and redirects it to twins. No base URL configuration, no SDK mocking.What to expect on the first run
Firstvitest run: ~30 seconds while the control plane provisions an ECS-hosted twin in AWS. Subsequent runs within the same 30-minute session TTL finish in ~2 seconds — the session is cached by a stable hash of (name, services, seeds).
Seeds
Seeds control the twin’s starting state. Omitseed: to get a twin’s default empty state. Pass a named seed for a known fixture (e.g. small-project on GitHub gives you one repo with a few issues and PRs). Named seeds are documented per twin in Seeds.
Reset state between tests
Inspect the session
If you need to check which services, seeds, or versions the backend resolved:Troubleshooting
- Real API responses instead of twin responses — your test file isn’t matched by the project’s
includeglob. - 401 at setup —
ARCHAL_TOKENisn’t set (orarchal loginwasn’t run). - Test hangs for 30+ seconds on first run — that’s the ECS cold-start, not a hang.
- Reset isn’t working — call
resetArchalTwins()inbeforeEach, notbeforeAll. - CI credential race — when multiple jobs run in parallel, export
ARCHAL_TOKENdirectly instead of relying on~/.archal/credentials.json.