Skip to main content
testsprite ci run starts one project run and waits for its verdict. A failed or blocked test, or a cancelled execution, fails the gate. Add --fail-on-skipped to fail when a selected test was skipped. testsprite ci init github writes a GitHub Actions workflow that runs it against each pull request’s preview.

Set up the pull-request gate

1

Add your API key as a repository secret

Mint the key in the workspace the project belongs to. It is tied to the member who minted it and stops working if they leave or are removed from the workspace, so mint it from an account that will stay. Save it as the TESTSPRITE_API_KEY secret under Settings → Secrets and variables → Actions, or pass --set-secret in the next step to set it through gh.
GitHub Actions secrets page with the New repository secret button
2

Generate the workflow

Set PROJECT_ID to the ID from testsprite project list and replace staging with your saved environment name. The CLI writes both into .github/workflows/testsprite.yml. An unknown environment is refused. --project can be left out when the workspace has only one project, and --dry-run prints the file without writing it. The generated pull-request workflow skips fork, Dependabot and draft pull requests. It passes --fail-on-skipped to the gate.
3

Tell it where the preview is

The file has one placeholder step, marked REPLACE ME. Replace it to match how your pull requests get a public preview:
  • Your platform deploys every pull request (Vercel or Netlify): change the trigger to on: deployment_status and delete the placeholder.
  • Your workflow deploys: keep on: pull_request, put your deploy commands in the placeholder and end it with echo "url=<preview address>" >> "$GITHUB_OUTPUT".
  • Your platform only posts a check or commit status: keep the pull-request trigger, delete the placeholder and use the status-based example below.
These examples use the repository variable TESTSPRITE_PROJECT_ID. Set it under Settings → Secrets and variables → Actions → Variables, or keep the literal project ID from the generated workflow.
If your platform also deploys pull requests from forks, turn that off (on Vercel, require authorization for fork deployments). A deployment_status workflow runs with your repository’s secrets, so a fork could run its own edit of it with your TESTSPRITE_API_KEY.
4

Open a pull request

Commit the workflow, open a pull request that isn’t a draft, and watch the TestSprite / testsprite-tests check. To block merges on it, require testsprite-tests in branch protection.
Your coding agent can do all four steps, including the test pull request: testsprite agent install includes a testsprite-ci skill. See Coding Agent Integration.
  • The generated pull-request job skips drafts. A draft identified by ci run itself also skips testing.
  • A pull request with merge conflicts never starts pull_request workflows, and GitHub shows no error.
  • If none of the repository’s workflows run, Actions is disabled, which is common on forks.
  • With deployment_status, check that a successful deployment event arrived for the commit.
The platform sends one deployment event per project for the same commit (Preview – <project> on Vercel). Add && github.event.deployment.environment == 'Preview – <project>' to the job’s if: to gate on one of them.

What you get

  • A check on the pull request. A failed or blocked test exits 1. A timeout (default 600 seconds) or unconfirmed run settings exit 7. Cancelling the job leaves the TestSprite run active in the Portal.
  • A GitHub job summary and annotations. When available, the execution report supplies the job summary. The CLI falls back to its results table if the report is unavailable. Anyone with read access to the repository can read it.
  • testsprite-summary.json, uploaded as the testsprite-results artifact. Individual outcomes are in .results[], with resultId and runId on dispatched results. The optional execution report identifies the run with .executionReport.runId. Use --report junit --report-file testsprite.xml for a JUnit sidecar.
  • One run in the Portal, linked to the pull request. With --env and a preview URL, the run uses a temporary copy of that environment named github-pr-<N>. The copy points at the preview and is removed when the run ends. For frontend previews, use a public or username/password sign-in compatible with the preview origin.

Test staging after deployment

Run the gate after your deployment job confirms staging is ready. Set TESTSPRITE_API_KEY and TESTSPRITE_PROJECT_ID in the job’s environment. This command selects the existing staging environment:
For backend tests, the selected environment supplies the API base URL to tests that use it. A URL written directly into test code stays as written. On a pull request, a preview clone supplies the preview URL to tests using the environment’s base URL. Every other exit code is in Exit Codes.

Coding Agent Integration

Let your agent drive the verification loop

Exit Codes

Every exit code and what to do about it