@testsprite/testsprite-cli 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/commands/ci.d.ts +66 -17
- package/dist/commands/ci.js +466 -104
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.js +50 -9
- package/dist/commands/init.js +17 -3
- package/dist/commands/project.js +15 -1
- package/dist/commands/test.d.ts +74 -11
- package/dist/commands/test.js +579 -112
- package/dist/index.js +5 -1
- package/dist/lib/agent-targets.d.ts +8 -3
- package/dist/lib/agent-targets.js +15 -4
- package/dist/lib/ci-run.d.ts +11 -0
- package/dist/lib/ci-run.js +34 -0
- package/dist/lib/client-factory.d.ts +23 -0
- package/dist/lib/client-factory.js +7 -6
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +1 -1
- package/dist/lib/credentials.d.ts +0 -1
- package/dist/lib/credentials.js +51 -14
- package/dist/lib/dry-run/samples.js +42 -1
- package/dist/lib/first-suite-hint.d.ts +55 -0
- package/dist/lib/first-suite-hint.js +101 -0
- package/dist/lib/gh-output.d.ts +62 -4
- package/dist/lib/gh-output.js +149 -7
- package/dist/lib/github-context.d.ts +21 -0
- package/dist/lib/github-context.js +153 -0
- package/dist/lib/http.d.ts +10 -1
- package/dist/lib/http.js +9 -1
- package/dist/lib/plans.types.d.ts +1 -1
- package/dist/lib/response-schemas.d.ts +5 -1
- package/dist/lib/response-schemas.js +54 -0
- package/dist/lib/runs.types.d.ts +106 -0
- package/dist/lib/telemetry.d.ts +25 -1
- package/dist/lib/telemetry.js +45 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schemas/plan.schema.json +2 -2
- package/skills/testsprite-ci.skill.md +154 -0
package/README.md
CHANGED
|
@@ -203,6 +203,8 @@ See [the full local-testing reference](./DOCUMENTATION.md#local-frontend-testing
|
|
|
203
203
|
| | `schedule update` | Retime or rename a schedule, change recipients, pin a project schedule with `--env <name>`, or `--pause` / `--resume` it |
|
|
204
204
|
| | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
|
|
205
205
|
| | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
|
|
206
|
+
| **CI** | `ci init github` | Write a GitHub Actions PR gate that runs `ci run` against each pull request's preview deployment — one placeholder step to fill in: your platform deploys every PR (`on: deployment_status`) or the workflow deploys |
|
|
207
|
+
| | `ci run` | The CI gate in one command: every project test (or `--filter`) against `--target-url`, signed in as `--env`, in a temporary `github-pr-<N>` environment, one execution; waits and exits with the verdict. Job summary = the execution report (the GitHub App comment); `--summary-file`, `--report junit`, step outputs |
|
|
206
208
|
| **Agent** | `agent install` / `agent list` / `agent status` | Add, list, or health-check coding-agent skills (pure-local): `claude`, `codex`, `cursor`, `cline`, `antigravity`, `kiro`, `windsurf`, `copilot` |
|
|
207
209
|
|
|
208
210
|
> The earlier command names — `init`, `auth configure`, `auth whoami`, `auth logout` — still work as hidden, deprecated aliases (each prints a one-line notice pointing at the new name), so existing scripts keep running. `auth configure` now runs the full `setup` (it also installs the skill).
|
|
@@ -215,7 +217,7 @@ See [the full local-testing reference](./DOCUMENTATION.md#local-frontend-testing
|
|
|
215
217
|
- 🤖 **Agent-shaped output.** `test failure get` returns **one bundle** — the failing step, its neighbors, screenshots, DOM snapshots, the test source, a root-cause hypothesis, and a recommended fix target — all sharing a single `snapshotId`. The CLI _refuses_ to stitch data from two different runs, so an agent never reasons over a frankenstein context.
|
|
216
218
|
- ♻️ **A loop, not a one-shot.** `create → run → failure get → fix → rerun` — every pass is banked, not thrown away.
|
|
217
219
|
- 📐 **Scriptable & deterministic.** Stable `--output json` contract, predictable [exit codes](./DOCUMENTATION.md#exit-codes), and a `--dry-run` that exercises the full code path offline with canned data.
|
|
218
|
-
- 🚦 **CI-native.**
|
|
220
|
+
- 🚦 **CI-native.** `testsprite ci init github` writes a PR gate; `testsprite ci run --env <name> --target-url "$PREVIEW_URL"` tests each pull request's preview deployment as one execution and exits with the verdict. The job summary is the execution report — the same content as the GitHub App's PR comment — plus `::error::` annotations on the checks tab, step outputs, `--summary-file` for a machine summary and `--report junit` for a JUnit sidecar. In any other CI, `testsprite ci run --project <id> --env <name> --target-url <url>` still runs the suite as one execution and makes the exit code the verdict — the pull-request context, draft skip and job summary are GitHub Actions only. [Details →](./DOCUMENTATION.md#continuous-integration)
|
|
219
221
|
- 🔌 **One command to onboard your agent.** `testsprite setup` drops ready-made skill files into your repo — for the agents it detects you using — so your coding agent knows how to drive the loop on its own.
|
|
220
222
|
|
|
221
223
|
## How it works
|
package/dist/commands/ci.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
4
4
|
import { type FetchImpl } from '../lib/http.js';
|
|
5
5
|
import { type DeploymentRecord, type LinkageStatus } from '../lib/ci-linkage.js';
|
|
6
|
+
import { type RunTestRunAllOptions, type TestDeps } from './test.js';
|
|
6
7
|
/** Platforms `ci init` can scaffold. One today; the positional arg leaves room. */
|
|
7
8
|
declare const SUPPORTED_PLATFORMS: readonly ["github"];
|
|
8
9
|
type Platform = (typeof SUPPORTED_PLATFORMS)[number];
|
|
@@ -17,16 +18,18 @@ export interface CiFs {
|
|
|
17
18
|
}): Promise<void>;
|
|
18
19
|
mkdir(dir: string): Promise<void>;
|
|
19
20
|
readFile(target: string): Promise<string>;
|
|
21
|
+
/** Entry names in `dir`; rejects with ENOENT when the directory is absent. */
|
|
22
|
+
readdir(dir: string): Promise<string[]>;
|
|
20
23
|
}
|
|
21
24
|
/** Injectable subprocess runner (defaults to a real `spawnSync`), so tests never
|
|
22
|
-
* shell out. Runs `git` (
|
|
23
|
-
*
|
|
25
|
+
* shell out. Runs `git` (repo slug), `gh` (optional secret set, deployment
|
|
26
|
+
* history) and `npx vercel` (`ci connect`). */
|
|
24
27
|
export type SpawnImpl = (cmd: string, args: string[], opts: {
|
|
25
28
|
input?: string;
|
|
26
29
|
cwd?: string;
|
|
27
30
|
shell?: boolean;
|
|
28
31
|
}) => SpawnSyncReturns<string>;
|
|
29
|
-
export interface CiDeps {
|
|
32
|
+
export interface CiDeps extends Pick<TestDeps, 'shutdown' | 'onWaitTimeout'> {
|
|
30
33
|
env?: NodeJS.ProcessEnv;
|
|
31
34
|
credentialsPath?: string;
|
|
32
35
|
fetchImpl?: FetchImpl;
|
|
@@ -44,8 +47,10 @@ type CommonOptions = FactoryCommonOptions;
|
|
|
44
47
|
export interface CiInitOptions extends CommonOptions {
|
|
45
48
|
platform: string;
|
|
46
49
|
project?: string;
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
/** `--env`: the environment whose sign-in each PR run uses (default: the project's default). */
|
|
51
|
+
env?: string;
|
|
52
|
+
/** `--timeout`, written into the `ci run` line only when given. */
|
|
53
|
+
timeoutSeconds?: number;
|
|
49
54
|
workflowPath: string;
|
|
50
55
|
force: boolean;
|
|
51
56
|
setSecret: boolean;
|
|
@@ -55,18 +60,22 @@ export interface CiInitOptions extends CommonOptions {
|
|
|
55
60
|
export interface CiInitSummary {
|
|
56
61
|
platform: Platform;
|
|
57
62
|
path: string;
|
|
58
|
-
action: string;
|
|
59
63
|
projectId: string;
|
|
64
|
+
/** The environment written into `ci run --env`. */
|
|
65
|
+
environment: string;
|
|
60
66
|
wrote: boolean;
|
|
61
67
|
/** Distinguishes the two `wrote: false` cases a scripted caller can't otherwise
|
|
62
68
|
* tell apart: `preview` (a --dry-run) vs `unchanged` (the file was already
|
|
63
69
|
* byte-identical). `written` is the wrote-true case. */
|
|
64
70
|
status: 'written' | 'unchanged' | 'preview';
|
|
65
|
-
backupPath: string | null;
|
|
66
|
-
filter: string | null;
|
|
67
71
|
endpointUrl: string | null;
|
|
68
72
|
endpointWarning: string | null;
|
|
69
|
-
|
|
73
|
+
/** `--timeout` as written into the workflow; null when `ci run`'s default applies. */
|
|
74
|
+
timeoutSeconds: number | null;
|
|
75
|
+
/** Other workflows in `.github/workflows/` that already mention TestSprite. */
|
|
76
|
+
otherTestspriteWorkflows: string[];
|
|
77
|
+
/** `--force` over an edited file: where the previous file was kept. */
|
|
78
|
+
backupPath?: string;
|
|
70
79
|
secret: {
|
|
71
80
|
name: string;
|
|
72
81
|
attempted: boolean;
|
|
@@ -75,19 +84,25 @@ export interface CiInitSummary {
|
|
|
75
84
|
};
|
|
76
85
|
}
|
|
77
86
|
export declare function parseTimeoutSeconds(raw: unknown): number;
|
|
87
|
+
/** `--execution-report-timeout <s>`: same bounds as `--timeout`, its own default. */
|
|
88
|
+
export declare function parseExecutionReportTimeoutSeconds(raw: unknown): number;
|
|
78
89
|
/**
|
|
79
|
-
* Build the GitHub Actions workflow. It
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
90
|
+
* Build the GitHub Actions workflow. It calls the CLI directly (`ci run`), which
|
|
91
|
+
* owns every judgement — waiting, skipped counts, the exit code, the PR
|
|
92
|
+
* context — so the yml only moves data.
|
|
93
|
+
*
|
|
94
|
+
* One template covers both ways a PR gets a preview, because they differ only
|
|
95
|
+
* in where the URL comes from. The trigger, `if:` and concurrency already accept
|
|
96
|
+
* both events; the single placeholder step is the part only the repo owner can
|
|
97
|
+
* write, and it fails loudly until replaced so the gate can never run against a
|
|
98
|
+
* URL nobody chose.
|
|
83
99
|
*/
|
|
84
100
|
export declare function buildGithubWorkflow(input: {
|
|
85
101
|
projectId: string;
|
|
86
|
-
|
|
87
|
-
timeoutSeconds
|
|
102
|
+
environment: string;
|
|
103
|
+
timeoutSeconds?: number;
|
|
88
104
|
endpointUrl?: string;
|
|
89
|
-
|
|
90
|
-
defaultBranch: string;
|
|
105
|
+
workflowPath: string;
|
|
91
106
|
}): string;
|
|
92
107
|
export declare function runCiInit(opts: CiInitOptions, deps?: CiDeps): Promise<void>;
|
|
93
108
|
export interface CiDoctorOptions extends CommonOptions {
|
|
@@ -169,5 +184,39 @@ export interface CiConnectSummary {
|
|
|
169
184
|
export declare function runCiConnect(opts: CiConnectOptions, deps?: CiDeps): Promise<void>;
|
|
170
185
|
export declare function renderCiConnectText(s: CiConnectSummary): string;
|
|
171
186
|
export declare function renderCiInitText(s: CiInitSummary): string;
|
|
187
|
+
export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission' | 'previewName' | 'githubTrigger'> & {
|
|
188
|
+
failOnSkipped?: boolean;
|
|
189
|
+
/** `--execution-report-timeout`: how long to wait for the execution report (default 60). */
|
|
190
|
+
executionReportTimeoutSeconds?: number;
|
|
191
|
+
/** `--no-execution-report`: job summary stays the local table; nothing is read or written for the report. */
|
|
192
|
+
executionReport?: boolean;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* `ci run` = `test run --all --wait` with CI's defaults, plus what only a CI
|
|
196
|
+
* job can add:
|
|
197
|
+
*
|
|
198
|
+
* - `admission: 'all'` — one request, one execution, server-side pacing (as
|
|
199
|
+
* for a GitHub App run), so a PR run is one row in the Portal and, in a
|
|
200
|
+
* pull request, one `github-pr-<N>` environment. The backend echoes the
|
|
201
|
+
* field; a backend that cannot honour it is refused (exit 7), never
|
|
202
|
+
* silently cut to the per-key budget and retried.
|
|
203
|
+
* - In a pull request (read off the Actions event, or looked up from the
|
|
204
|
+
* deployment's commit), `--env X --target-url U` runs in a temporary clone
|
|
205
|
+
* of X at U named `github-pr-<N>`, and the run is stamped with the PR so
|
|
206
|
+
* the Portal links back to it — the GitHub App's own mechanism.
|
|
207
|
+
* - Outside a pull request the run keeps `test run`'s semantics: X's sign-in
|
|
208
|
+
* against U, recorded under X.
|
|
209
|
+
*/
|
|
210
|
+
export declare function runCiRun(opts: CiRunOptions, deps?: TestDeps): Promise<void>;
|
|
172
211
|
export declare function createCiCommand(deps?: CiDeps): Command;
|
|
212
|
+
/**
|
|
213
|
+
* One stderr line per run of a deprecated `ci` subcommand, naming the
|
|
214
|
+
* equivalent commands (stdout stays clean for JSON pipelines). The
|
|
215
|
+
* replacements are not `testsprite` commands, so this does not reuse
|
|
216
|
+
* `emitDeprecationNotice`.
|
|
217
|
+
*/
|
|
218
|
+
export declare const CI_DEPRECATION_NOTICES: {
|
|
219
|
+
readonly doctor: string;
|
|
220
|
+
readonly connect: string;
|
|
221
|
+
};
|
|
173
222
|
export {};
|