> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spurtest.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Spur is an AI-powered QA engineer that lets teams create and run automated end-to-end tests for web and mobile apps using natural language.
> When answering questions about Spur, cite the relevant page from docs.spurtest.com.

# Spur CLI

> Run Spur tests from your terminal or any CI pipeline with the Spur CLI, and fail the build when a test fails.

## Overview

The Spur CLI (`@spurtest/cli` on npm) runs your Spur tests from a terminal or a CI job. It waits for the run, prints each test's result with a link to it in Spur, and exits with a non-zero code when a test fails, so your pipeline can block a merge or deploy.

## Before you begin

* Node.js 22.12 or later.
* A Spur account with access to the Application whose tests you want to run.

## Sign in

On your own computer, sign in with your browser:

```bash theme={null}
npx @spurtest/cli login
```

The CLI keeps you signed in and refreshes the session on its own. Run `npx @spurtest/cli logout` to sign out.

In CI, use an API key instead. Generate one under **Integrations → MCP**, as described in [API key (no OAuth)](https://docs.spurtest.com/analysing-tests/mcp/spur-mcp-setup.md#api-key-no-oauth), store it as a secret in your CI provider, and expose it to the CLI as the `SPUR_API_KEY` environment variable. It's a different key from the [GitHub integration](https://docs.spurtest.com/running-tests/cicd/github.md) key, so store it under its own secret name, such as `SPUR_MCP_API_KEY`.

## Find tests and environments

| Command | What it does |
| - | - |
| `npx @spurtest/cli apps [name]` | Lists your Applications, or switches the active one |
| `npx @spurtest/cli tests [test-id]` | Lists tests, or shows one test |
| `npx @spurtest/cli envs` | Lists environments |

## Run tests

```bash theme={null}
npx @spurtest/cli run <test-ids…> -e <environment>
```

Pass one or more test IDs and the environment name. Options:

| Option | Description |
| - | - |
| `-e <environment>` | Environment to run in. Required. |
| `--url <url>` | Runs against this URL instead of the environment's, like `default` in [Override URLs](https://docs.spurtest.com/running-tests/cicd/override-urls.md). Use a URL Spur can reach. |
| `--map <domain>=<url>` | Replaces one environment domain with another URL, like `domains` in [Override URLs](https://docs.spurtest.com/running-tests/cicd/override-urls.md). |
| `-H <name>=<value>` | Sends a header only to the `--url` and `--map` hosts, for example a deploy preview's protection-bypass header. The value is saved with the run and visible in the runner's process list, so use a token you can rotate, not a password, and prefer a runner you don't share. |
| `--scenario <row>` | Runs one row of the test's Scenario Table. |
| `--browser`, `--viewport` | Overrides the browser or viewport for the run. |
| `--name <run name>` | Names the run. |
| `--no-wait` | Starts the run and returns without waiting for results, so no `--junit` report is written. |
| `--timeout <duration>` | How long to wait for results. Defaults to `60m`. When it runs out, the run keeps going in Spur. |
| `--json` | Prints the results as JSON. |
| `--junit <file.xml>` | Writes a JUnit XML report for your CI's test view. |

### Exit codes

| Code | Meaning |
| - | - |
| `0` | Every test you asked for passed. With `--no-wait`, Spur accepted the run, but no results were checked. |
| `1` | A test you asked for failed or didn't run. Tests that Spur adds to the run, such as a suite's dependent tests, don't affect the exit code. |
| `2` | The command is invalid (for example, `-e` is missing), Spur returns an error, or the wait times out. |
| `130` | The run was interrupted. |

### Run in CI

This GitHub Actions step runs two tests against a deploy preview that needs a Vercel protection-bypass header, and writes a JUnit report. It reads the preview URL from an earlier step with the id `deploy` and the output `preview_url`; replace both with your own deploy step's.

Both secrets are yours, stored in your GitHub repository: `SPUR_MCP_API_KEY` is the API key you created in Spur, and `VERCEL_AUTOMATION_BYPASS_SECRET` is your Vercel project's **Protection Bypass for Automation** secret.

```yaml theme={null}
- name: Run Spur tests
  env:
    SPUR_API_KEY: ${{ secrets.SPUR_MCP_API_KEY }}
    VERCEL_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
    PREVIEW_URL: ${{ steps.deploy.outputs.preview_url }}
  run: |
    test -n "$PREVIEW_URL" || { echo "No preview URL from the deploy step"; exit 1; }
    npx -y @spurtest/cli run 123 456 -e Preview \
      --url "$PREVIEW_URL" \
      -H "x-vercel-protection-bypass=$VERCEL_BYPASS_SECRET" \
      --junit spur.xml
```

The step fails if a requested test fails or doesn't run. To block merges on failure, make the job that contains this step a required check.

## Corporate proxies

Set `HTTPS_PROXY` (and `NO_PROXY` as needed) for the CLI's connections to Spur, even if the proxy itself speaks plain HTTP: Spur's addresses are HTTPS, so `HTTP_PROXY` alone doesn't apply to them. If your proxy inspects TLS, add its CA certificate with `NODE_EXTRA_CA_CERTS`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.