testsprite-cli README

The project's README from github.com/TestSprite/testsprite-cli. As one markdown file: README.md.

TestSprite

The verification layer for the agentic coding era.

AI ships code in minutes — verifying it hasn't. testsprite opens your live app, uses it like a real user, and shows your coding agent exactly what broke — so it fixes its own work before a bug ever reaches you.

Proof, in public: verification beats model size. With this CLI in the loop, the cheapest model in the field shipped the most correct app on an open leaderboard — 89%, at half the cost of the priciest one. See the leaderboard →

npm version npm downloads Node 20.19+, 22.13+, or 24+ License Apache 2.0 CI

Website Docs Follow on X LinkedIn Join our Discord

⭐ Help us reach more developers and grow the TestSprite community. Star this repo!

▶ Watch the launch video — the three hard limits every coding agent hits, and the loop that breaks them (4 min).


What is it?

TestSprite is the AI testing platform 100,000+ teams use to test their software, frontend and backend — in the cloud, against the live product, not mocks. This repo is its official CLI.

It puts that platform in your coding agent's hands: the agent verifies every behavior it ships, and what broke comes back as one self-consistent bundle it can act on — no dashboard scraping. Humans drive the same surface from a terminal or CI.

⭐️ Star the Repository

testsprite-repo-star-fast

If you find testsprite useful, a GitHub Star ⭐️ would be greatly appreciated — it helps other builders (and their agents) find the project, and stars notify you about new releases.

Quickstart

Requires Node.js 20.19+, 22.13+, or 24+. (No global install? npx @testsprite/testsprite-cli works too.)

npm install -g @testsprite/testsprite-cli
testsprite setup

testsprite setup prompts for your API key, verifies it, and installs the verification-loop skill for the coding agents this project uses — one command, so your agent is wired to verify its own work.

Which agent it installs for. Each of the eight supported targets — claude, cursor, cline, windsurf, antigravity, kiro, copilot, codex — lands its skill in a different place, so setup works out which you use: the agent calling it, if it identifies itself, together with every agent whose config is already in the project. It installs for all of them and prints what it found — in a terminal it shows you that list first, so you can accept it or narrow it before anything is written. If nothing identifies an agent, it installs for claude and says so — that is the one case where you want --agent <target> to name one yourself. Check the result any time with testsprite agent status.

Non-interactive (CI / onboarding scripts):

TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yes

Pointing a coding agent (Claude Code, Cursor, Codex, Cline, …) at TestSprite? Have it run testsprite setup first — that installs the verification skill, so the agent knows how to create, run, and triage tests on its own (instead of guessing from this README). setup reports which agents it installed for; add --agent <target> if that list is not the one you wanted. New here? Start with the getting-started overview.

Privacy note: interactive runs check the npm registry at most once per 24 h to offer a "new version available" notice — package name only, never your key or data; TESTSPRITE_NO_UPDATE_NOTIFIER=1 disables it. The backend also advertises its minimum supported CLI version — a below-floor CLI prints a one-line upgrade advisory on stderr, and a too-old client may be rejected with exit 14 (CLIENT_TOO_OLD). Details in DOCUMENTATION.md → Update notice.

From there, the loop runs on its own — an example session, typed by the coding agent:

# 1 — describe the behavior you want to guarantee, run it, wait
testsprite test create --project proj_8f0f6 --type frontend \
  --plan-from ./checkout-flow.plan.json --run --wait --output json
#   → exits 1: the run failed

# 2 — pull ONE self-consistent failure bundle
testsprite test failure get test_3a9f21c7 --out ./.testsprite/failure

# 3 — the agent reads the bundle, fixes the code, then replays
testsprite test rerun test_3a9f21c7 --wait --output json
#   → exits 0: passed. The test now lives in your durable suite.

./checkout-flow.plan.json (the --plan-from argument above) is a JSON file describing the test in plain language — no browser code required. This is the exact, byte-identical output of testsprite test create --plan-template (also embedded verbatim in test create --help):

{
  "$schema": "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.4.0/schemas/plan.schema.json",
  "projectId": "prj_abc123",
  "type": "frontend",
  "name": "Login rejects an empty password",
  "planSteps": [
    {
      "type": "action",
      "description": "Navigate to /login and submit the form with an empty password"
    },
    {
      "type": "assertion",
      "description": "Verify an inline error says the password is required"
    }
  ]
}

Get this exact skeleton without hand-copying it (and without the risk of it drifting from your installed version — see below): testsprite test create --plan-template. Full field reference (including the {{...}}-placeholder caveat, size caps, and the $schema hook for live editor validation): Plan file format.

The $schema URL above is pinned to the CLI version that generated this doc (v0.4.0) — --plan-template's live output always pins to your installed version instead, which is what actually resolves. If you're reading this on a later release, run the command yourself rather than trusting this snippet verbatim.

Don't want to write the first tests yourself? For a deployed target, ask TestSprite to propose them. Local projects use the authored-plan flow below. testsprite test plan generate --project <id> explores your app (or reads the API spec you uploaded with project docs upload), drafts test cases, and stages them for review — nothing is written to your disk. You read the printed table and keep what you want:

testsprite test plan generate --project proj_8f0f6           # stages proposals for review
testsprite test plan accept --project proj_8f0f6             # → real tests
testsprite test plan accept --project proj_8f0f6 --only prop_2 prop_5   # or just these

It only runs what the project is still missing, so a second call picks up where the first left off. Generation spends workspace credits per stage that actually runs (the result line reports the spend), and a PRD uploaded with project docs upload --role prd bills 0.5 credits for its embedding — an API spec is free. Full walkthrough, including what happens on Ctrl-C and every precondition error: Generate commands.

Prefer to configure each step by hand (or learn the surface offline with --dry-run first)? See Manual setup and Install & verify.

Testing an app on your machine (--local)

Frontend tests can reach your running app through a TestSprite tunnel, including on the Free plan (ordinary run credits apply). Use an API key with run:tunnel: keys minted before that scope existed need to be replaced; the CLI names the missing scope.

testsprite project create --type frontend --name "My local app" --local 3000
testsprite test create --plan-from ./checkout.plan.json --project <project-id>
testsprite test run <test-id> --local 3000  # waits up to 1200 seconds
testsprite test run <id> <id> --local 3000 --max-concurrency 5
testsprite test run --all --project <project-id> --local 3000
# Or keep one tunnel open in terminal A (no port argument)
testsprite tunnel start --ttl 3600
# Terminal B: borrow the clientId printed above; keep terminal A running
testsprite test run <test-id> --local 3000 --tunnel-client <client-uuid>
testsprite tunnel list
testsprite tunnel stop <client-uuid>
# Stop every live tunnel on this account only when you intend to revoke them all
testsprite tunnel stop --all --confirm

Run several local frontend tests in one invocation to share one tunnel binding. The batch runs up to 5 tests at once by default; --max-concurrency accepts 1–10. --all --local skips backend tests. An owned batch cancels unfinished runs on Ctrl-C or tunnel loss; JSON output lists every requested test in input order, including tests that did not start. The minted client id is printed before the tunnel connects. Hit the tunnel limit? Run testsprite tunnel list, then testsprite tunnel stop <client-uuid> for an unused binding, or testsprite tunnel stop --all --confirm to revoke them all. An older server without listing returns exit 4; a key without run:tunnel returns exit 3. A second tunnel start or process using the same credential takes over, and the first exits 10. The examples use 127.0.0.1. For another loopback listener, pass the same --local-host localhost or --local-host ::1 to project creation and every follow-up run. The selected host is stored in the project URL (::1 becomes http://[::1]:<port>); project get/list exposes originMode: 'local' in JSON and shows (Local) in text output. The control plane is WebSocket over TLS (wss://control.tun.testsprite.com/ws). The data plane, which carries the tunnel secret and proxied traffic, uses TLS at data.tun.testsprite.com:443 and verifies the certificate with Node's default trust store: its bundled Mozilla roots, plus certificates supplied through NODE_EXTRA_CA_CERTS and the system CAs when Node is started with --use-system-ca. Node 20 is supported without losing NODE_EXTRA_CA_CERTS. Verification cannot be disabled, and the CLI never falls back from TLS to plaintext. On a network that re-signs TLS, export your organisation's root CA to a PEM file and set NODE_EXTRA_CA_CERTS=/path/to/ca.pem before running testsprite. Plaintext connects and TLS handshakes each time out after 10 seconds. The first failed attempt starts a 60-second retry episode; writing TunnelHello is not enough to reset it. The episode ends only after the first inbound tunnel stream or after the socket remains open for 5 seconds following the hello. A real deadline timer stays armed across retries and destroys an in-flight socket when it expires. After that, an owned test run --local run is cancelled and refunded and the command exits 10; tunnel start exits 10. If a self-hosted or older TestSprite server does not advertise a TLS endpoint, the CLI prints a one-time warning and uses legacy plaintext port 7400 under the same timeout and retry rules. tunnel start prints transport: tls or transport: plaintext. An owned tunnel's timeout or Ctrl-C cancels unfinished runs by default. A borrowed run still detaches without cancellation on Ctrl-C/SIGTERM because its owner keeps the tunnel alive; if that owner disappears while a run is active, the borrower cancels its own run and reports cancelled, already finished, or skipped. A run cancelled before it finishes is refunded. --no-cancel-on-interrupt also skips this owner-gone cancellation. Keep the early stderr run-id receipts (Run <runId> for one test, [i/N] <testId> → run <runId> for a batch) and read the reported runs before re-running. Local projects skip exploration/plan generation; author plans with test create --plan-from. Portal runs are blocked for free until you set a public project URL. See the full local-testing reference for flags, login, billing/refunds, timeouts, and retargeting.

Commands

Group Command What it does
Setup setup Start here — one command: configure your API key, verify it, and install the agent verification skill
doctor Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure
Auth auth status Resolve the active profile to its user, key, env, and scopes
auth remove Remove the active profile from the credentials file
usage (alias credits) Account pre-flight: identity, plus credit balance / plan info when the backend supplies them
Read project list / project get List projects / fetch one by id
test list / test get List tests under a project / fetch one by id
test code get Print (or write) the generated test source
test steps List the latest run's steps with screenshot / DOM pointers
test result Latest result; --history lists a test's prior runs (ENV column; --env <name> filters by environment)
test failure get The agent entry point: one self-contained latest-failure bundle
test failure summary One-screen triage card (no media download)
test diff Compare two runs — verdict, failure kind, per-step status flips, code-version drift
Write test scaffold / test lint Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials
test create / test create-batch Create a test (or bulk-create from a plan file); --step-timeout <ms> sets a per-test timeout; dependency flags wire BE metadata
test update / test delete / test delete-batch Edit metadata, set/clear the step timeout (--step-timeout / --clear-step-timeout), or permanently delete (--confirm required)
test code put Replace generated code (etag-guarded)
test plan put Replace a frontend test's plan-steps
project create / project update / project delete Manage projects; --test-id-attributes <list> registers the app's own test-hook attributes (priority order) for exported locators, --clear-test-id-attributes reverts; delete removes a project and everything under it (--confirm required, no restore window)
project credential / project auto-auth Configure backend-test auth: a static injected credential, or auto-refresh login (Pro)
project env list / create / update / delete / set-default Manage a project's environments — named URL + login bundles that test run --env <name> selects. An app on your own machine is named with --local <port> instead of --url — the same spelling as project create — and run with test run --local <port>; delete refuses the default environment
Generate test plan generate Ask TestSprite to propose test cases for a project — proposals are staged server-side for review, never written to disk; only the stages the project is missing actually run
test plan accept Turn staged proposals into real tests — all of them, or a subset with --only
project docs upload Upload an API spec or PRD as a project source, so generation has something to read
Run test run Trigger a fresh run; --wait blocks until terminal; --all --project <id> runs all tests in a project in wave order --env <name> runs against a named environment.
test rerun Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); --all --project <id> reruns all tests --env <name> replays against a named environment.
test flaky Replay a test several times (auto-heal off) and report a stability score
test wait Block on one or more runIds until terminal
test cancel Cancel one or more in-flight runs (Ctrl-C during --wait only detaches, cancel is the real stop — except an owned --local run, which Ctrl-C cancels by default)
test artifact get Download the failure bundle for a specific runId
Test lists testlist list / testlist get Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only)
testlist create / update / add / remove / delete Manage a list and its cases; --project-env <id>:<env> pins environments; delete requires --confirm
testlist run Run every case (or a --case subset) through its pinned environment; --wait polls all runs, --report junit writes a CI sidecar
Schedule schedule list / schedule get List schedules visible to the key / fetch one by id (status is ENABLED, PAUSED, or AUTO_PAUSED after repeated failures)
schedule create Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced
schedule update Retime or rename a schedule, change its recipients, --pause / --resume it
schedule delete Remove a schedule and its run history, stopping future triggers (--confirm required, no restore window)
schedule run list A schedule's past runs, with per-run pass / fail / blocked counts
Agent agent install / agent list / agent status Add, list, or health-check coding-agent skills (pure-local): claude, codex, cursor, cline, antigravity, kiro, windsurf, copilot

The earlier command names — init, auth configure, auth whoami, auth logout — still work as hidden, deprecated aliases (each prints a one-line notice pointing at the new name), so existing scripts keep running. auth configure now runs the full setup (it also installs the skill).

📚 Full reference — every command, flag, and example: DOCUMENTATION.md, including configuration & profiles, scripting, and exit codes.

Why a CLI for coding agents?

How it works

Every time your agent changes code, it asks one question: is this behavior already covered by the suite?

Every pass is banked into a durable suite, so coverage compounds as the project grows — a lasting record of every requirement it has ever gotten right, far bigger than any context window.

flowchart TD
    A["🤖 Your coding agent<br/>Claude Code · Codex · Antigravity · Kimi · Cursor · Trae …"]
    D{"behavior already<br/>covered by the suite?"}
    B["<b>testsprite test create</b><br/>new behavior → new test"]
    R["<b>testsprite test rerun</b><br/>replay the existing tests"]
    C{{"☁️ TestSprite testing agent<br/>runs the test like a real user against<br/>real browsers & real APIs on Cloud"}}
    F["<b>testsprite test failure get</b><br/>ONE self-consistent bundle:<br/>failing step · screenshots · DOM ·<br/>root-cause · recommended fix"]
    S[("📚 Durable integration suite<br/>grows with every pass")]

    A -->|"writes / changes code"| D
    D -->|"no — new behavior"| B
    D -->|"yes"| R
    B --> C
    R --> C
    C -->|"pass ✅"| S
    C -->|"fail ❌"| F
    F -->|"agent reads the bundle<br/>& fixes the code"| A
    S -.->|"defines what's covered"| D

The cloud is a black box on purpose: your agent describes intent and reads results. It never has to know how the test was driven — only what a real user experienced.

Proved in public

On CoderCup — an open leaderboard where frontier coding agents build the same app under the same rules, with TestSprite as the referee — the cheapest model in the field shipped the most correct app on the board: 89%, at half the cost of the priciest one.

That's the point of all of this: you no longer need the biggest, most expensive model to ship software you can trust — top-tier quality, without paying top-tier prices, within reach of every team.

Getting help

Contributing

Contributions are welcome — the CLI is plain TypeScript/Node (20.19+, 22.13+, or 24+), tested with Vitest, built with tsc. Getting a dev loop running takes a minute:

git clone https://github.com/TestSprite/testsprite-cli.git
cd testsprite-cli && npm install
npm run build       # tsc → dist/ ; try it: node dist/index.js --help
npm test            # unit suite — no network or credentials needed
npm run lint:fix    # ESLint
npm run typecheck   # tsc --noEmit

Pull requests target the main branch. The full guide — build from source, test tiers, CI checks, branches, project layout — is in CONTRIBUTING.md.

Support — if you need any help, we're responsive on Discord, and feel free to email us at [email protected] too.

License

Apache-2.0 © TestSprite

testsprite-cli (TestSprite/testsprite-cli)

Searching Database…

这是什么?TestSprite 的官方命令行工具。TestSprite 是一个 AI 测试平台,已有超过 10 万个团队用它对前端和后端进行云端测试,测试对象是真实运行的产品而不是模拟数据 —— 发现问题后还会反馈给你的编程智能体,让它自己修复自己写的代码。
那这到底是云服务,还是跑在我电脑上的工具?两者都是:它是一个终端命令行工具,但测试在 TestSprite 云端执行,针对的是你真实运行的应用。同一套命令既可以由编程智能体调用,也可以由人在终端手动操作,还能接入 CI。
我怎么把它跑起来?需要 Node.js 20.19+、22.13+ 或 24+。运行 'testsprite setup'(或者不全局安装直接用 'npx @testsprite/testsprite-cli'):一条命令会让你输入 API key,验证有效性,然后把验证循环技能装进你的编程智能体。
它能接入哪些编程智能体?支持八个目标:claude、cursor、cline、windsurf、antigravity、kiro、copilot、codex。安装时会自动检测你在用哪些,并给它们装上对应技能;随时可以运行 'testsprite agent status' 查看结果。
在依赖它之前,有什么坑我需要提前知道?必须使用 TLS —— 命令行工具绝不会退回到明文传输,所以在会重新签名 TLS 的网络里,你需要把 NODE_EXTRA_CA_CERTS 指向你所在组织的根证书。免费版的门户运行在没有设置公开的项目 URL 之前也会一直被阻止。
只有用 AI 智能体写代码的人才用得上它吗?不是 —— 智能体循环是主打玩法,但人也可以在终端或 CI 里直接用同一套命令,它还提供了非交互式参数,方便在 CI 和初始化脚本里使用。
我用它的时候,有什么东西会离开我的电脑?测试流量通过 TestSprite 的 TLS 加密云隧道传输。唯一一次例行联网是最多每 24 小时一次的 npm 仓库版本查询,只发送包名,绝不会发送你的 key 或数据;可以通过环境变量把它关掉。
测试失败时,我的智能体能拿到什么信息?通过 'testsprite test failure get' 会得到一个自成一体的最新失败结果包 —— 包含判定结论,以及每一步的状态、截图和 DOM 定位 —— 设计目的就是让智能体能直接据此行动。'test failure summary' 会给出一屏大小的分诊卡片,'test diff' 则可以对比两次运行,包括每一步状态的翻转情况。
TestSprite 能帮我提出测试方案,而不是让我自己写吗?可以。'testsprite test plan generate --project' 会探索你的应用(或读取上传的 API 规范),起草测试用例,并暂存起来供你审阅,不会动你磁盘上的任何东西 —— 你留下想要的,去掉不要的。每个实际运行的阶段都会消耗积分;上传 PRD 会因嵌入处理计费 0.5 积分,而 API 规范是免费的。
我必须在线编写测试计划吗?不用。'test scaffold' 可以生成一份符合 schema 的起始测试计划,'test lint' 可以完全离线校验计划文件 —— 不联网、不需要凭据 —— 还能用 --dry-run 预览将要执行的命令。本地项目可以完全跳过探索步骤,直接通过 'test create --plan-from' 按照编写好的计划运行。
我怎么确认一切都配置正确?'testsprite doctor' 会做一次完整的环境诊断 —— 包括 CLI 和 Node 版本、配置档案、端点、凭据、网络连通性和智能体技能 —— 失败时会以非零状态码退出。'testsprite agent status' 则可以查看哪些编程智能体已经装上了验证技能。
Creator
TestSprite
Size
3.1 MB
Stars
4.7K
Age
4mo
Commits · 90 Days