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.
2
Generate the workflow
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_statusand delete the placeholder. - Your workflow deploys: keep
on: pull_request, put your deploy commands in the placeholder and end it withecho "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.
TESTSPRITE_PROJECT_ID. Set it under Settings → Secrets and variables → Actions → Variables, or keep the literal project ID from the generated workflow.- A — platform deploys every PR
- B — the workflow deploys (Vercel CLI shown)
- C — your platform posts a commit check
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.Nothing ran on my pull request
Nothing ran on my pull request
- The generated pull-request job skips drafts. A draft identified by
ci runitself also skips testing. - A pull request with merge conflicts never starts
pull_requestworkflows, 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.
One repository deploys several projects
One repository deploys several projects
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 exit7. 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 thetestsprite-resultsartifact. Individual outcomes are in.results[], withresultIdandrunIdon dispatched results. The optional execution report identifies the run with.executionReport.runId. Use--report junit --report-file testsprite.xmlfor a JUnit sidecar.- One run in the Portal, linked to the pull request. With
--envand a preview URL, the run uses a temporary copy of that environment namedgithub-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. SetTESTSPRITE_API_KEY and TESTSPRITE_PROJECT_ID in the job’s environment. This command selects the existing staging environment:
Coding Agent Integration
Let your agent drive the verification loop
Exit Codes
Every exit code and what to do about it