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.
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, a personal token (arc_...) or
archal login works. The first hosted session takes about 30 seconds;
later runs within the TTL reuse it.Install
ARCHAL_TOKEN instead of running archal login. For team CI
pipelines, use a workspace API key (archal_ws_...) created by an owner or
admin via archal workspace api-key create <label> --scope sessions:write.
Workspace keys are already bound to a workspace, so ARCHAL_WORKSPACE_ID is
usually unnecessary. 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,
reporter, and session env.
{} 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:
include glob will provision hosted clones; the rest run as normal Vitest.
Workspace mode requires a root
vitest.config.ts with archalVitestRootConfig().
Vitest only honors reporters from the root config, so without it route mode still
works but dashboard uploads are skipped. If you see no results on /dashboard/tests,
check that the root config is present.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.Seeds
Seeds control starting state. Omitseed: for the default state, or pass a
named seed such as small-project. See 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 clone 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
resetArchalClones()inbeforeEach, notbeforeAll. - CI credential race - when multiple jobs run in parallel, export
ARCHAL_TOKENdirectly instead of relying on~/.archal/credentials.json.
