Fail a build when your client handles API failures badly. jitterbox run switches a failure scenario on, runs
your test command with JITTERBOX_BASE_URL pointing at the project's mock, switches the scenario back off, then
grades the resilience report for exactly that run.
Setup
- In the project, create the endpoints your app calls (or an LLM endpoint) and a failure scenario, e.g. Rate-limited at peak.
- Settings → API keys → Create key. Copy it once and store it as a CI secret (
JITTERBOX_TOKEN). - Make your tests call
JITTERBOX_BASE_URLinstead of the real API, e.g.new OpenAI({ baseURL: process.env.JITTERBOX_BASE_URL + "/v1" }).
GitHub Actions
The Action lives in the CLI's repo:
- uses: MadhavKauntia/jitterbox-cli@v1
with:
token: ${{ secrets.JITTERBOX_TOKEN }}
scenario: Rate-limited at peak # several: one per line or comma-separated
command: npm test
# fail-on: warn # stricter: warnings fail too
# require: respects-retry-after,backs-off
# junit: jitterbox-junit.xml
It writes the report card to the job summary, adds an error annotation explaining a failure, and sets the
outputs result (passed|failed), exit-code and report (path to the JSON report).
Any CI: the CLI
JITTERBOX_TOKEN=jb_… npx jitterbox run --scenario "Rate-limited at peak" --junit report.xml -- npm test
| Command | What it does |
|---|---|
run --scenario <name|id> [--scenario …] -- <command> |
The full flow above |
report [--window 1h | --since <ISO>] [--scenario x] |
Grade traffic you already sent |
scenarios on|off|reset <name|id> |
Switch a scenario by hand |
whoami |
Show the token's project and mock base URL |
The CLI does much more with a personal token (projects, endpoints, scenarios, jitterbox.yaml): see
CLI and coding agents.
Options: --fail-on fail|warn (default fail), --require <checks>, --allow-empty, --report-json <file>,
--json (print the report as JSON),
--junit <file>, --markdown <file>, --wait <seconds> (default 600), --no-lease, --holder <name>,
--keep-on, --api <url> (or JITTERBOX_API; default https://jitterbox.dev).
Exit codes: 0 passed · the command's own code if your tests failed · 3 report failed · 4 no requests
reached Jitterbox · 5 timed out waiting for the lease · 2 usage error · 6 bad token · 7 not found ·
8 not allowed.
What fails a run
- Any check with FAIL (e.g. ignored
Retry-After, retrying within 200 ms, retrying a 422). Warnings, such as "no Idempotency-Key at all", don't fail the run unless you pass--fail-on warn. --requirenames checks that must pass. A required check that nothing exercised ("not tested") fails, so the run can't pass just because the scenario never triggered.- No requests at all: almost always a test setup that still calls the real API. Use
--allow-emptyto accept it.
One run at a time per project
Scenarios apply to the whole project, so run takes a lease (5 minutes, renewed every 2 minutes) before
switching anything. A second run waits for it (--wait) instead of interfering, and an abandoned lease expires
on its own. Use one project per pipeline to avoid waiting at all. The scenario's on/off state is read under
the lease and restored afterwards, even if the tests crash.
API keys
API keys are scoped to one project and to CI only: they can read the project, scenarios, endpoints, requests and
reports, switch and reset scenarios, and take the lease. They can't create or change mocks, see other projects,
or manage keys. Only a hash is stored; the key is shown once. Revoke it under Settings → API keys. (A personal
token from jitterbox login also works for run, with your full access.)
API: Authorization: Bearer jb_…; GET /api/token (who am I); POST /api/projects/{id}/lease
{holder, ttlSeconds, leaseId?} returns 200 with {leaseId, expiresAt, serverTime}, or 409 if another run holds
it; DELETE /api/projects/{id}/lease/{leaseId}.
Token management (session only): GET/POST /api/projects/{id}/tokens, DELETE /api/tokens/{id}.