CLI
The CLI runs test files from your repository against a staging URL. Each file becomes one task, and each test case gets its own result. Run it locally or as a CI step after a deploy.
Install
The CLI needs Node.js 20 or later.
npm install --save-dev @timetotest/cli@beta
npx ttt initttt init creates .ttt/config.json and an example test, tests/example.e2e.ts. It does not overwrite existing files. ttt collect then lists the cases and steps that would run, without calling our servers.
Create a key
In the project's Settings, click Create key under CLI keys. Name it after where it is used and choose when it expires: 30 days, 90 days or 1 year. Copy the key from Key created. It is shown once. Only project admins can create keys.
The key identifies the project, so you do not pass a project ID.
export TTT_API_KEY="ttt_pk_..."Keep the key in your environment or CI secrets. The CLI never prints it or writes it to disk.
Write a test
Save test files as tests/*.e2e.ts. By default the CLI collects every *.e2e.ts, *.e2e.js, *.e2e.mts and *.e2e.mjs file in the project.
import { test, expect } from 'e2e';
test.describe('checkout', () => {
test('a member pays with a saved card', async ({ app, agent, screen }) => {
await app.open('/cart');
await agent.act('Sign in with the staging member account');
await agent.act('Pay with the saved Visa card');
await expect(screen.getByText('Order confirmed')).toBeVisible();
await agent.assert('The order number is shown');
});
});The CLI reads test files without running them. agent.act becomes a step and agent.assert or expect becomes a result the agent checks. Loops, helper calls and interpolated strings are rejected with the file and line.
Supported: test, test.describe, test.skip, beforeEach, afterEach, app.open, agent.act, agent.assert, agent.waitFor, and screen.getByRole, getByText or getByTestId with toBeVisible, toBeHidden, toHaveText, toContainText or toHaveValue. The agent judges these assertions; they are not run through a locator engine.
The format follows tester.army test files, which has more examples.
Run
npx ttt collect
npx ttt run --url https://staging.example.com
npx ttt run tests/checkout.e2e.ts --url https://staging.example.com
npx ttt run --resumecollect lists the cases that would run, without calling our servers. run submits them and waits for the result. --resume reconnects to the last batch.
| Option | Use |
|---|---|
--url URL | Staging URL to test. Required unless --resume. |
--include GLOB, --exclude GLOB | Choose files. --include replaces the configured include; --exclude adds to it. |
--grep PATTERN | Run cases whose describe and test titles match. |
--sha SHA, --pr N | Deployed commit and pull request, sent from GitHub Actions. |
--file-timeout-minutes N | How long the CLI waits for each file, 1 to 1440. Default 30. |
--no-wait | Submit, print the batch link and exit. |
--resume | Wait for the saved batch instead of submitting a new one. |
GitHub Actions
Add a step after the deploy job. This example assumes the deploy job outputs the staging URL, commit SHA and pull request number.
- name: Test staging
run: npx ttt run --url "$STAGING_URL" --sha "$DEPLOYED_SHA" --pr "$PR_NUMBER"
env:
TTT_API_KEY: ${{ secrets.TTT_API_KEY }}
STAGING_URL: ${{ needs.deploy.outputs.staging_url }}
DEPLOYED_SHA: ${{ needs.deploy.outputs.commit_sha }}
PR_NUMBER: ${{ needs.deploy.outputs.pr_number }}Omit --pr when there is no pull request. Upload .ttt/ as an artifact even when the job fails. With the project's GitHub App connected, results also appear on the pull request.
Results
Failed cases print what was expected, what happened, steps to reproduce and evidence. Reports are written to .ttt/report.json, .ttt/junit.xml and .ttt/summary.md. Commit .ttt/config.json and nothing else in .ttt/.
| Exit code | Meaning |
|---|---|
0 | Every case that ran passed. |
1 | At least one case failed. |
2 | Setup, authentication, collection or submission error, or no reliable result. |
3 | Blocked: no case failed, but one could not finish, for example because of a missing credential or an unreachable URL. |
130 | Interrupted. The CLI asks us to cancel the batch. |
Environment variables
| Variable | Use |
|---|---|
TTT_API_KEY | Project key. Required for ttt run. |
TTT_API_URL | API base URL, when not using the default. |
TTT_TELEMETRY_DISABLED | Set to 1 to turn off CLI telemetry. |