| name | testsprite-ai-testing-cli |
| description | Official TestSprite CLI for AI-powered automated testing — create, run, and verify frontend & backend tests from terminal |
| triggers | ["run automated tests with TestSprite","create AI-powered E2E tests","verify my app with TestSprite CLI","set up TestSprite testing agent","get test failure details from TestSprite","integrate TestSprite into CI pipeline","rerun failed tests with TestSprite","configure TestSprite authentication"] |
TestSprite AI Testing CLI
Skill by ara.so — Devtools Skills collection.
TestSprite CLI is the command-line interface for TestSprite's AI-powered testing platform. It enables coding agents and developers to create, run, and verify automated tests against live applications (frontend with Playwright, backend API tests) — no mocks, real browsers and APIs in the cloud. The CLI is designed for agent-driven verification loops: create test → run → get failure bundle → fix → rerun.
Installation
Requirements: Node.js ≥ 20
npm install -g @testsprite/testsprite-cli
npx @testsprite/testsprite-cli <command>
Quick Start
One-Shot Setup (Interactive)
testsprite init
This command:
- Prompts for your TestSprite API key (get one at https://www.testsprite.com)
- Stores credentials at
~/.testsprite/credentials
- Verifies authentication
- Optionally installs agent skill files for your coding agent
Non-Interactive Setup (CI/Scripts)
export TESTSPRITE_API_KEY=sk-your-key-here
testsprite init --from-env --yes --agent claude
Manual Authentication
testsprite auth configure
testsprite auth whoami
testsprite status
testsprite auth logout
Core Workflow: The Verification Loop
The CLI is designed for a test-driven agent loop:
1. Create a Test
testsprite test create \
--project proj_8f0f6 \
--type frontend \
--name "Checkout flow completes successfully" \
--plan-from ./test-plans/checkout.plan.json
testsprite test create \
--project proj_8f0f6 \
--type backend \
--name "POST /api/orders creates order and returns 201" \
--produces order_created \
--category orders
2. Run the Test
testsprite test create \
--project proj_8f0f6 \
--type frontend \
--plan-from ./checkout.plan.json \
--run \
--wait \
--output json > result.json
echo $?
3. Handle Failures (Agent Entry Point)
testsprite test failure get test_3a9f21c7 \
--out ./.testsprite/failure
Example failure.json structure:
{
"testId": "test_3a9f21c7",
"runId": "run_a8f2e1b4",
"status": "failed",
"failingStep": {
"index": 3,
"action": "click",
"selector": "#checkout-submit",
"error": "Element not found: #checkout-submit"
},
"context": {
"beforeStep": { "index": 2, "screenshot": "step-2.png" },
"afterStep": { "index": 4, "screenshot": "step-4.png"
4. Rerun After Fix
testsprite test rerun test_3a9f21c7 \
--wait \
--output json
Project Management
testsprite project list --output json
testsprite project get proj_8f0f6
testsprite project create \
--name "E-commerce Frontend" \
--description "Main storefront tests"
testsprite project update proj_8f0f6 \
--name "Updated Name"
Test Management
List & Retrieve Tests
testsprite test list --project proj_8f0f6
testsprite test get test_3a9f21c7
testsprite test code get test_3a9f21c7 --out ./tests/checkout.spec.ts
testsprite test result test_3a9f21c7 --history
testsprite test steps test_3a9f21c7
Create Tests
Frontend test with plan file:
testsprite test create \
--project proj_8f0f6 \
--type frontend \
--name "User can login successfully" \
--plan-from ./plans/login.plan.json \
--category authentication
Backend test with dependencies:
testsprite test create \
--project proj_8f0f6 \
--type backend \
--name "GET /api/orders/:id returns order details" \
--needs order_created \
--category orders
Batch create from file:
testsprite test create-batch --from ./batch-tests.json
Update & Delete Tests
testsprite test update test_3a9f21c7 \
--name "Updated test name" \
--category checkout
testsprite test plan put test_3a9f21c7 \
--from ./updated-plan.json
testsprite test code put test_3a9f21c7 \
--from ./custom-test.ts \
--etag "abc123def456"
testsprite test delete test_3a9f21c7
testsprite test delete-batch test_3a9f21c7 test_4b8c92d8
Running Tests
Single Test Run
testsprite test run test_3a9f21c7
testsprite test run test_3a9f21c7 --wait --output json
testsprite test wait run_a8f2e1b4
Bulk Operations
testsprite test run --all --project proj_8f0f6 --wait
testsprite test rerun --all --project proj_8f0f6 --wait
Get Artifacts from Specific Run
testsprite test artifact get run_a8f2e1b4 \
--out ./.testsprite/runs/run_a8f2e1b4
Test Plan Files (Frontend)
Frontend tests require a plan JSON file describing user actions:
checkout.plan.json:
{
"steps": [
{
"action": "navigate",
"url": "https://example.com/cart"
},
{
"action": "click",
"selector": "#proceed-to-checkout"
},
{
"action": "fill",
"selector": "#email",
"value": "test@example.com"
},
{
"action": "fill",
"selector": "#card-number",
"value": "4242424242424242"
},
{
"action": "click",
Available actions: navigate, click, fill, select, check, uncheck, hover, wait, assert
Agent Integration
Install skill files for your coding agent:
testsprite agent install claude
testsprite agent install cursor
testsprite agent install cline
testsprite agent install codex
testsprite agent install antigravity
testsprite agent list
This creates skill/instruction files in your project so the agent can autonomously drive the verification loop.
Configuration & Profiles
Credentials File
Location: ~/.testsprite/credentials
{
"profiles": {
"default": {
"apiKey": "sk-your-key-here",
"environment": "production"
},
"staging": {
"apiKey": "sk-staging-key",
"environment": "staging"
}
},
"activeProfile": "default"
}
Environment Variables
export TESTSPRITE_API_KEY=sk-your-key-here
export TESTSPRITE_API_URL=https://api.testsprite.com
export TESTSPRITE_PROFILE=staging
export TESTSPRITE_API_KEY=sk-key
testsprite init --from-env --yes --agent claude
Output Formats
testsprite test get test_3a9f21c7
testsprite test get test_3a9f21c7 --output json
testsprite test run test_3a9f21c7 --quiet
Exit Codes
The CLI uses consistent exit codes for scripting:
- 0 - Success (test passed, operation succeeded)
- 1 - Test failed (assertions failed, test did not pass)
- 2 - Error (API error, invalid arguments, network issue)
Example script usage:
#!/bin/bash
testsprite test rerun test_3a9f21c7 --wait --output json > result.json
if [ $? -eq 0 ]; then
echo "✅ Test passed"
elif [ $? -eq 1 ]; then
echo "❌ Test failed - getting failure details"
testsprite test failure get test_3a9f21c7 --out ./failures
else
echo "⚠️ Error running test"
fi
Common Agent Patterns
Pattern 1: New Feature Verification
const createResult = await execCommand(`
testsprite test create \
--project ${projectId} \
--type frontend \
--name "New dashboard widget loads data" \
--plan-from ./test-plans/dashboard-widget.plan.json \
--run \
--wait \
--output json
`);
if (createResult.exitCode === 1) {
await execCommand(`
testsprite test failure get ${testId} \
--out ./.testsprite/failure
`);
const failureData = await readJson('./.testsprite/failure/failure.json');
await fixCodeBasedOnFailure(failureData);
await execCommand(`
testsprite test rerun ${testId} --wait --output json
`);
}
Pattern 2: Regression Guard
const testsResult = await execCommand(`
testsprite test list \
--project ${projectId} \
--output json
`);
const affectedTests = JSON.parse(testsResult.stdout)
.filter(t => t.category === 'checkout');
for (const test of affectedTests) {
const result = await execCommand(`
testsprite test rerun ${test.id} --wait --output json
`);
if (result.exitCode === 1) {
await handleRegression(test.id);
}
}
Pattern 3: CI Integration
#!/bin/bash
set -e
testsprite test rerun --all --project $PROJECT_ID --wait --output json > results.json
FAILED=$(jq '[.[] | select(.status == "failed")] | length' results.json)
if [ "$FAILED" -gt 0 ]; then
echo "❌ $FAILED test(s) failed"
jq -r '.[] | select(.status == "failed") | .id' results.json | while read testId; do
testsprite test failure get "$testId" --out "./artifacts/$testId"
done
exit 1
fi
echo "✅ All tests passed"
Common Issues & Solutions
Authentication Errors
testsprite auth whoami
testsprite auth logout
testsprite auth configure
Test Creation Fails
{
"steps": [
{ "action": "navigate", "url": "..." },
// ... more steps
]
}
testsprite test create --plan-from ./plan.json --dry-run
Tests Stuck in "running" Status
testsprite test result test_abc123
testsprite test steps test_abc123
Missing Failure Artifacts
testsprite test result test_abc123
testsprite test artifact get run_xyz789 --out ./failures
Network/Timeout Issues
echo $TESTSPRITE_API_URL
curl -I https://api.testsprite.com/health
testsprite test run test_abc123 --verbose
Advanced Usage
Dependency Management (Backend Tests)
Backend tests can declare what data they produce/need:
testsprite test create \
--project proj_8f0f6 \
--type backend \
--name "Create order" \
--produces order_created \
--category orders
testsprite test create \
--project proj_8f0f6 \
--type backend \
--name "Get order details" \
--needs order_created \
--category orders
testsprite test rerun --all --project proj_8f0f6
Using --dry-run for Local Validation
testsprite test create \
--project proj_8f0f6 \
--type frontend \
--plan-from ./plan.json \
--dry-run
Scripting with JSON Output
TEST_ID=$(testsprite test create \
--project proj_8f0f6 \
--type frontend \
--plan-from ./plan.json \
--output json | jq -r '.id')
testsprite test run $TEST_ID --wait
testsprite test list --project proj_8f0f6 --output json | \
jq '.[] | select(.status == "failed") | .id'
Resources
License
Apache-2.0 — see LICENSE file in repository