Skip to main content
Use archal/vitest when you want hosted clones inside an existing Vitest suite. Your tests keep using normal SDK clients; Archal supplies the clone session and routes supported service traffic during the test run. For the full API surface, see the archal/vitest SDK reference. For a runnable Stripe route-mode project, see examples/vitest-route-mode in the repository.
archal/vitest needs an auth token. Run archal login locally, or set ARCHAL_TOKEN in CI. For CI, use a workspace API key (archal_ws_...); for local dev, archal login works too. The first hosted session takes about 30 seconds; later runs within the TTL reuse it.

Install

In CI, set ARCHAL_TOKEN instead of running archal login. Use a workspace API key (archal_ws_...). See the CI integration guide for full details. Route mode supports Discord, GitHub, Google Workspace, Jira, Linear, Ramp’s primary API domain, Slack, Stripe, and Supabase.

Add Archal to your existing vitest.config.ts

If your project already has a vitest.config.ts, wrap test: with withArchal. It preserves your existing test config and adds Archal’s setup, and session env.
If you’re starting from scratch, pass {} 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 clones, use a workspace:
Only tests matching the include glob will provision hosted clones; the rest run as normal Vitest.

Write a test

Your test code uses normal SDK clients or direct HTTP calls. Route mode redirects supported service traffic to clones, so there is no SDK mock or base URL setup.
First run takes about 30 seconds. Subsequent runs reuse the cached session.

Seeds

Seeds control starting state. Omit seed: for the default state, or pass a named seed such as small-project. See Seeds.

Reset state between tests

This restores each clone to its post-seed state and drains the webhook queue. No cold-start - it’s a local state snapshot reapplied to the existing session.

Inspect the session

If you need to check which services, seeds, or versions the backend resolved:

Troubleshooting

  • Real API responses instead of clone responses - your test file isn’t matched by the project’s include glob.
  • 401 at setup - ARCHAL_TOKEN isn’t set (or archal login wasn’t run).
  • Test hangs for 30+ seconds on first run - that’s the ECS cold-start, not a hang.
  • Reset isn’t working - call resetArchalClones() in beforeEach, not beforeAll.
  • CI credential race - when multiple jobs run in parallel, export ARCHAL_TOKEN directly instead of relying on ~/.archal/credentials.json.