DOCS
Automate

Run tests in CI

Run a project's tests after every deploy, fail the build when a check fails, and keep the result with the commit. One file, no dependencies, any CI.

Before you start#

  1. Create an API key. Settings → API keys → Create key, with "Run tests and read results". It is shown once.
  2. Store it as a secret named TESTSY_AI_API_KEY in your CI (GitHub: Settings → Secrets and variables → Actions; GitLab: a masked CI/CD variable).
  3. Find your project id. It starts with p_ and is in the address of the project page, or run node testsy-ai.mjs projects. The app's Connect page shows these snippets with your project filled in.

Add the workflow#

Run it after your deploy finishes, so the tests see the new version: on GitHub, on deployment_status, or as the last step of your deploy job.

Connect: the workflow with your project already filled in.
Connect: the workflow with your project already filled in.
# .github/workflows/testsy-ai.yml
name: Testsy
on:
  deployment_status:
  workflow_dispatch:
jobs:
  qa:
    if: github.event_name == 'workflow_dispatch' || github.event.deployment_status.state == 'success'
    runs-on: ubuntu-latest
    steps:
      - name: Run Testsy tests
        env:
          TESTSY_AI_API_KEY: ${{ secrets.TESTSY_AI_API_KEY }}
          TESTSY_AI_URL: https://app.testsy.dev
          TARGET: ${{ github.event.deployment_status.environment_url }}
        run: |
          curl -fsSL "$TESTSY_AI_URL/cli/testsy-ai.mjs" -o testsy-ai.mjs
          # On a deployment event the tests run against that deploy's address (a preview or staging of the same site).
          node testsy-ai.mjs run --project p_your_project --junit testsy-ai-junit.xml ${TARGET:+--url "$TARGET"}
      - uses: actions/upload-artifact@v4
        if: always()
        with: { name: testsy-ai-junit, path: testsy-ai-junit.xml }

On GitHub the published action does the same with less to copy — uses: testsy-ai/testsy-action@v1 with api-key, project or tests, and the optional build, build-label, fingerprint, target-url, device, os-version, mode, timeout, fail-on, junit and url inputs; it exposes junit and watch-urls as outputs. Given fingerprint and no build, it only looks the build up and sets build-needed and build-id (skipping the build). Pin a commit SHA in production. The snippet above downloads the same CLI at run time instead, which works in any CI.

The GitLab template takes these variables: TESTSY_AI_PROJECT, TESTSY_AI_TESTS (test ids instead of a whole project), TESTSY_AI_MODE (auto), TESTSY_AI_TIMEOUT (45m), TESTSY_AI_FAIL_ON (failed,error), TESTSY_AI_BUILD (app builds: files, https links or ab_ ids, separated by spaces), TESTSY_AI_FINGERPRINT (stored with a single uploaded build), TESTSY_AI_URL, TESTSY_AI_TARGET_URL, TESTSY_AI_DEVICE and TESTSY_AI_OS_VERSION. Results appear in the merge request's test report.

Results stay with the commit. Each run records the CI, commit, branch and job and links back to the job. On GitHub a table of results is added to the job's summary. The JUnit file shows each test as passed or failed, with the link to its proof.
Anyone can watch. Each started run prints a watch link (unless your workspace turned them off) that opens the run live, and its result afterwards, without a Testsy account — paste it in the pull request or a chat. The GitHub Action exposes them as the watch-urls output. Runs from a public repository get a link only workspace members can open.

Test a preview or staging deploy#

A test is saved with the address of your site. In CI you usually want the same test against *this* deploy — a pull request's preview, a review app, staging. Give the run the address and every website test starts there instead:

The run explores from that address (a learned path belongs to the saved one), the result shows the address it ran against, and app tests are unaffected — they run their build. Sign-in accounts and endpoints are the test's own; a preview that needs other credentials needs its own test.

App tests on another device#

Each app test is saved with its device and OS version (a phone on the latest version unless you chose otherwise). To run the suite on another one this time — an iPad, or an older Android — give the run the device, the version and/or the orientation at the start (default, portrait, landscape); the tests keep their own setting:

A version applies to every app test of the run. In a project with both iPhone and Android tests, use latest or a device alone, or run each platform's tests separately (--test).

Versions: latest, or one of those list devices returns (iOS 27, 26, 18, 17; Android 16 to 10). Website tests are unaffected. A run on another device explores (a learned path belongs to the saved device), and its result says what it ran on.

When the build fails#

By default the build fails when a run fails or does not finish. Change it with --fail-on (GitLab: TESTSY_AI_FAIL_ON):

ValueThe runFails the build by default
failedA check failed.Yes
errorDid not finish because of a problem on our side. Not counted.Yes
blockedThe site stopped the tester, for example a bot wall. Not counted.No
inconclusiveThe tester could not tell for sure.No

Exit codes#

CodeMeaning
0Every run passed, or none ended in a --fail-on verdict.
1A run ended in a --fail-on verdict.
2A setup or API problem: a missing key, an unknown project, no runs started, or a test that could not start.
3Timed out (--timeout, default 45m). The JUnit file is still written.

App builds#

Upload the build your pipeline just made and run the app's tests on it: see App builds from CI.

⌂ Proxy