@testsprite/testsprite-cli 0.9.0 → 0.10.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 +40 -40
- package/dist/commands/project.d.ts +21 -0
- package/dist/commands/project.js +104 -9
- package/dist/commands/test.d.ts +1 -1
- package/dist/lib/dry-run/samples.js +16 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-onboard.skill.md +6 -0
- package/skills/testsprite-verify.skill.md +5 -1
package/README.md
CHANGED
|
@@ -130,46 +130,46 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
|
|
|
130
130
|
|
|
131
131
|
## Commands
|
|
132
132
|
|
|
133
|
-
| Group | Command | What it does
|
|
134
|
-
| -------------- | ---------------------------------------------------------- |
|
|
135
|
-
| **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill
|
|
136
|
-
| | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure
|
|
137
|
-
| **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes
|
|
138
|
-
| | `auth remove` | Remove the active profile from the credentials file
|
|
139
|
-
| | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them
|
|
140
|
-
| **Read** | `project list` / `project get` | List projects / fetch one by id
|
|
141
|
-
| | `test list` / `test get` | List tests under a project / fetch one by id
|
|
142
|
-
| | `test code get` | Print (or write) the generated test source
|
|
143
|
-
| | `test steps` | List the latest run's steps with screenshot / DOM pointers
|
|
144
|
-
| | `test result` | Latest result; `--history` lists a test's prior runs
|
|
145
|
-
| | `test failure get` | The agent entry point: one self-contained latest-failure bundle
|
|
146
|
-
| | `test failure summary` | One-screen triage card (no media download)
|
|
147
|
-
| | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift
|
|
148
|
-
| **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials
|
|
149
|
-
| | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--step-timeout <ms>` sets a per-test timeout; dependency flags wire BE metadata
|
|
150
|
-
| | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required)
|
|
151
|
-
| | `test code put` | Replace generated code (etag-guarded)
|
|
152
|
-
| | `test plan put` | Replace a frontend test's plan-steps
|
|
153
|
-
| | `project create` / `project update` / `project delete` | Manage projects; `delete` removes a project and everything under it (`--confirm` required, no restore window)
|
|
154
|
-
| | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro)
|
|
155
|
-
| **Generate** | `test plan generate` | Ask TestSprite to propose test cases for a project — proposals are staged server-side for review, never written to disk; only the stages the project is missing actually run
|
|
156
|
-
| | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only`
|
|
157
|
-
| | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read
|
|
158
|
-
| **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order
|
|
159
|
-
| | `test rerun` | Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); `--all --project <id>` reruns all tests
|
|
160
|
-
| | `test flaky` | Replay a test several times (auto-heal off) and report a stability score
|
|
161
|
-
| | `test wait` | Block on one or more `runId`s until terminal
|
|
162
|
-
| | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except a `--local` run, which Ctrl-C cancels by default)
|
|
163
|
-
| | `test artifact get` | Download the failure bundle for a specific `runId`
|
|
164
|
-
| **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only)
|
|
165
|
-
| | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm`
|
|
166
|
-
| | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar
|
|
167
|
-
| **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures)
|
|
168
|
-
| | `schedule create` | Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced
|
|
169
|
-
| | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it
|
|
170
|
-
| | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window)
|
|
171
|
-
| | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts
|
|
172
|
-
| **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`
|
|
133
|
+
| Group | Command | What it does |
|
|
134
|
+
| -------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
135
|
+
| **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
|
|
136
|
+
| | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
|
|
137
|
+
| **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
|
|
138
|
+
| | `auth remove` | Remove the active profile from the credentials file |
|
|
139
|
+
| | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
|
|
140
|
+
| **Read** | `project list` / `project get` | List projects / fetch one by id |
|
|
141
|
+
| | `test list` / `test get` | List tests under a project / fetch one by id |
|
|
142
|
+
| | `test code get` | Print (or write) the generated test source |
|
|
143
|
+
| | `test steps` | List the latest run's steps with screenshot / DOM pointers |
|
|
144
|
+
| | `test result` | Latest result; `--history` lists a test's prior runs |
|
|
145
|
+
| | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
|
|
146
|
+
| | `test failure summary` | One-screen triage card (no media download) |
|
|
147
|
+
| | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
|
|
148
|
+
| **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
|
|
149
|
+
| | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--step-timeout <ms>` sets a per-test timeout; dependency flags wire BE metadata |
|
|
150
|
+
| | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
|
|
151
|
+
| | `test code put` | Replace generated code (etag-guarded) |
|
|
152
|
+
| | `test plan put` | Replace a frontend test's plan-steps |
|
|
153
|
+
| | `project create` / `project update` / `project delete` | Manage projects; `--test-id-attributes <list>` registers the app's own test-hook attributes (priority order) for exported locators, `--clear-test-id-attributes` reverts; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
|
|
154
|
+
| | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
|
|
155
|
+
| **Generate** | `test plan generate` | Ask TestSprite to propose test cases for a project — proposals are staged server-side for review, never written to disk; only the stages the project is missing actually run |
|
|
156
|
+
| | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
|
|
157
|
+
| | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
|
|
158
|
+
| **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order |
|
|
159
|
+
| | `test rerun` | Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); `--all --project <id>` reruns all tests |
|
|
160
|
+
| | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
|
|
161
|
+
| | `test wait` | Block on one or more `runId`s until terminal |
|
|
162
|
+
| | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except a `--local` run, which Ctrl-C cancels by default) |
|
|
163
|
+
| | `test artifact get` | Download the failure bundle for a specific `runId` |
|
|
164
|
+
| **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
|
|
165
|
+
| | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
|
|
166
|
+
| | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar |
|
|
167
|
+
| **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
|
|
168
|
+
| | `schedule create` | Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced |
|
|
169
|
+
| | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it |
|
|
170
|
+
| | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
|
|
171
|
+
| | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
|
|
172
|
+
| **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` |
|
|
173
173
|
|
|
174
174
|
> 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).
|
|
175
175
|
|
|
@@ -42,7 +42,22 @@ export interface CliProject {
|
|
|
42
42
|
* (see the `project create --type backend` note in CLAUDE.md).
|
|
43
43
|
*/
|
|
44
44
|
targetUrl?: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Project-level test-id attribute priority list (e.g. `['data-element',
|
|
47
|
+
* 'data-testid']`). The execution engine tries these DOM attributes, in
|
|
48
|
+
* order, before any other locator strategy when it exports test code, so
|
|
49
|
+
* customers who tag their UI with their own attribute get
|
|
50
|
+
* `page.locator('[data-element="…"]')` locators. Absent on older backends;
|
|
51
|
+
* `null`/empty means "not configured" (engine default: `data-testid`).
|
|
52
|
+
*/
|
|
53
|
+
testIdAttributes?: string[] | null;
|
|
45
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse `--test-id-attributes <list>`: a comma-separated, ordered list of DOM
|
|
57
|
+
* attribute names. Trims, drops empties and duplicates (first occurrence
|
|
58
|
+
* wins — order is the priority), rejects invalid names. Exported for tests.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseTestIdAttributesFlag(raw: string, flagName: string): string[];
|
|
46
61
|
export interface ProjectDeps {
|
|
47
62
|
env?: NodeJS.ProcessEnv;
|
|
48
63
|
credentialsPath?: string;
|
|
@@ -72,6 +87,8 @@ export interface CliCreateProjectRequest {
|
|
|
72
87
|
username?: string;
|
|
73
88
|
password?: string;
|
|
74
89
|
instruction?: string;
|
|
90
|
+
/** Ordered test-id attribute list — see `CliProject.testIdAttributes`. */
|
|
91
|
+
testIdAttributes?: string[];
|
|
75
92
|
}
|
|
76
93
|
/**
|
|
77
94
|
* Response shape for `POST /projects`.
|
|
@@ -106,6 +123,7 @@ interface CreateOptions extends CommonOptions {
|
|
|
106
123
|
name: string;
|
|
107
124
|
targetUrl?: string;
|
|
108
125
|
description?: string;
|
|
126
|
+
testIdAttributes?: string[];
|
|
109
127
|
username?: string;
|
|
110
128
|
password?: string;
|
|
111
129
|
passwordFile?: string;
|
|
@@ -140,6 +158,9 @@ interface UpdateOptions extends CommonOptions {
|
|
|
140
158
|
password?: string;
|
|
141
159
|
passwordFile?: string;
|
|
142
160
|
instruction?: string;
|
|
161
|
+
/** Ordered test-id attribute list; `clearTestIdAttributes` sends `null` to unset. */
|
|
162
|
+
testIdAttributes?: string[];
|
|
163
|
+
clearTestIdAttributes?: boolean;
|
|
143
164
|
idempotencyKey?: string;
|
|
144
165
|
}
|
|
145
166
|
export declare function runUpdate(opts: UpdateOptions, deps?: ProjectDeps): Promise<CliUpdateProjectResponse>;
|
package/dist/commands/project.js
CHANGED
|
@@ -12,6 +12,37 @@ import { assertNotLocal } from '../lib/target-url.js';
|
|
|
12
12
|
import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
|
|
13
13
|
import { assertIdempotencyKey } from '../lib/validate.js';
|
|
14
14
|
import { fetchSinglePage, paginate, validatePaginationFlags, } from '../lib/pagination.js';
|
|
15
|
+
/** Attribute names are interpolated into CSS selectors by the engine — keep them plain. */
|
|
16
|
+
const TEST_ID_ATTRIBUTE_NAME = /^[A-Za-z_][\w.:-]*$/;
|
|
17
|
+
const TEST_ID_ATTRIBUTES_MAX = 10;
|
|
18
|
+
/**
|
|
19
|
+
* Parse `--test-id-attributes <list>`: a comma-separated, ordered list of DOM
|
|
20
|
+
* attribute names. Trims, drops empties and duplicates (first occurrence
|
|
21
|
+
* wins — order is the priority), rejects invalid names. Exported for tests.
|
|
22
|
+
*/
|
|
23
|
+
export function parseTestIdAttributesFlag(raw, flagName) {
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
const attrs = [];
|
|
26
|
+
for (const part of raw.split(',')) {
|
|
27
|
+
const name = part.trim();
|
|
28
|
+
if (!name)
|
|
29
|
+
continue;
|
|
30
|
+
if (name.length > 64 || !TEST_ID_ATTRIBUTE_NAME.test(name)) {
|
|
31
|
+
throw localValidationError(`--${flagName}: '${name}' is not a valid attribute name (letters, digits, '_', '-', '.', ':'; must not start with a digit).`);
|
|
32
|
+
}
|
|
33
|
+
if (!seen.has(name)) {
|
|
34
|
+
seen.add(name);
|
|
35
|
+
attrs.push(name);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (attrs.length === 0) {
|
|
39
|
+
throw localValidationError(`--${flagName} needs at least one attribute name, e.g. --${flagName} data-element,data-testid`);
|
|
40
|
+
}
|
|
41
|
+
if (attrs.length > TEST_ID_ATTRIBUTES_MAX) {
|
|
42
|
+
throw localValidationError(`--${flagName} accepts at most ${TEST_ID_ATTRIBUTES_MAX} attribute names.`);
|
|
43
|
+
}
|
|
44
|
+
return attrs;
|
|
45
|
+
}
|
|
15
46
|
export async function runList(opts, deps = {}) {
|
|
16
47
|
const out = makeOutput(opts.output, deps);
|
|
17
48
|
const paginationFlags = validatePaginationFlags({
|
|
@@ -134,12 +165,19 @@ export async function runCreate(opts, deps = {}) {
|
|
|
134
165
|
...(opts.username !== undefined ? { username: opts.username } : {}),
|
|
135
166
|
...(password !== undefined ? { password } : {}),
|
|
136
167
|
...(opts.instruction !== undefined ? { instruction: opts.instruction } : {}),
|
|
168
|
+
...(opts.testIdAttributes !== undefined ? { testIdAttributes: opts.testIdAttributes } : {}),
|
|
137
169
|
};
|
|
138
170
|
const client = makeClient(opts, deps);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
171
|
+
let rawCreated;
|
|
172
|
+
try {
|
|
173
|
+
rawCreated = await client.post('/projects', {
|
|
174
|
+
body,
|
|
175
|
+
headers: { 'idempotency-key': idempotencyKey },
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
throw translateUnsupportedTestIdAttributes(err, body.testIdAttributes !== undefined);
|
|
180
|
+
}
|
|
143
181
|
// Normalize whichever id field name the backend actually
|
|
144
182
|
// sent onto BOTH `projectId` and `id`, so JSON consumers keyed on either
|
|
145
183
|
// name keep working regardless of which one the live response used.
|
|
@@ -219,6 +257,9 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
219
257
|
hintContext: 'bootstrap',
|
|
220
258
|
});
|
|
221
259
|
}
|
|
260
|
+
if (opts.testIdAttributes !== undefined && opts.clearTestIdAttributes) {
|
|
261
|
+
throw localValidationError('--test-id-attributes and --clear-test-id-attributes are mutually exclusive.');
|
|
262
|
+
}
|
|
222
263
|
const passwordSupplied = opts.password !== undefined || opts.passwordFile !== undefined;
|
|
223
264
|
const mutableFields = {
|
|
224
265
|
name: opts.name !== undefined,
|
|
@@ -226,12 +267,14 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
226
267
|
username: opts.username !== undefined,
|
|
227
268
|
password: passwordSupplied,
|
|
228
269
|
instruction: opts.instruction !== undefined,
|
|
270
|
+
testIdAttributes: opts.testIdAttributes !== undefined || opts.clearTestIdAttributes === true,
|
|
229
271
|
};
|
|
230
272
|
const presentFieldNames = Object.entries(mutableFields)
|
|
231
273
|
.filter(([, present]) => present)
|
|
232
274
|
.map(([field]) => field);
|
|
233
275
|
if (presentFieldNames.length === 0) {
|
|
234
|
-
throw localValidationError('At least one mutable flag is required: --name, --url, --username, --password/--password-file,
|
|
276
|
+
throw localValidationError('At least one mutable flag is required: --name, --url, --username, --password/--password-file, ' +
|
|
277
|
+
'--instruction, --test-id-attributes, or --clear-test-id-attributes.');
|
|
235
278
|
}
|
|
236
279
|
if (opts.dryRun) {
|
|
237
280
|
// DEV-247: emit the banner here (this path returns before makeClient() does).
|
|
@@ -269,13 +312,21 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
269
312
|
username: opts.username,
|
|
270
313
|
password,
|
|
271
314
|
instruction: opts.instruction,
|
|
315
|
+
// `null` clears the list server-side (same convention as `test update --clear-step-timeout`).
|
|
316
|
+
testIdAttributes: opts.clearTestIdAttributes ? null : opts.testIdAttributes,
|
|
272
317
|
};
|
|
273
318
|
const body = Object.fromEntries(Object.entries(bodyFields).filter(([, v]) => v !== undefined));
|
|
274
319
|
const client = makeClient(opts, deps);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
320
|
+
let rawUpdated;
|
|
321
|
+
try {
|
|
322
|
+
rawUpdated = await client.patch(`/projects/${encodeURIComponent(opts.projectId)}`, {
|
|
323
|
+
body,
|
|
324
|
+
headers: { 'idempotency-key': idempotencyKey },
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
catch (err) {
|
|
328
|
+
throw translateUnsupportedTestIdAttributes(err, 'testIdAttributes' in body);
|
|
329
|
+
}
|
|
279
330
|
// Normalize whichever id field name the backend actually
|
|
280
331
|
// sent onto BOTH `projectId` and `id`, so JSON consumers keyed on either
|
|
281
332
|
// name keep working regardless of which one the live response used.
|
|
@@ -893,6 +944,8 @@ export function createProjectCommand(deps = {}) {
|
|
|
893
944
|
.option('--password <pw>', 'optional auth password (use --password-file for non-interactive)')
|
|
894
945
|
.option('--password-file <path>', 'read password from file instead of inline flag')
|
|
895
946
|
.option('--instruction <text>', 'optional FE plan-gen instruction hint')
|
|
947
|
+
.option('--test-id-attributes <list>', 'comma-separated DOM attributes the engine should prefer as locators, highest priority first ' +
|
|
948
|
+
'(e.g. data-element,data-testid). Unique values are exported as page.locator(\'[attr="…"]\').')
|
|
896
949
|
.option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
|
|
897
950
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
898
951
|
.action(async (cmdOpts, command) => {
|
|
@@ -917,6 +970,9 @@ export function createProjectCommand(deps = {}) {
|
|
|
917
970
|
password: cmdOpts.password,
|
|
918
971
|
passwordFile: cmdOpts.passwordFile,
|
|
919
972
|
instruction: cmdOpts.instruction,
|
|
973
|
+
testIdAttributes: cmdOpts.testIdAttributes !== undefined
|
|
974
|
+
? parseTestIdAttributesFlag(cmdOpts.testIdAttributes, 'test-id-attributes')
|
|
975
|
+
: undefined,
|
|
920
976
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
921
977
|
}, deps);
|
|
922
978
|
});
|
|
@@ -929,6 +985,9 @@ export function createProjectCommand(deps = {}) {
|
|
|
929
985
|
.option('--password <pw>', 'new auth password')
|
|
930
986
|
.option('--password-file <path>', 'read new password from file')
|
|
931
987
|
.option('--instruction <text>', 'new FE plan-gen instruction hint')
|
|
988
|
+
.option('--test-id-attributes <list>', 'comma-separated DOM attributes the engine should prefer as locators, highest priority first ' +
|
|
989
|
+
'(e.g. data-element,data-testid); replaces the current list')
|
|
990
|
+
.option('--clear-test-id-attributes', 'remove the test-id attribute list (engine falls back to data-testid)', false)
|
|
932
991
|
.option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
|
|
933
992
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
934
993
|
.action(async (projectId, cmdOpts, command) => {
|
|
@@ -941,6 +1000,10 @@ export function createProjectCommand(deps = {}) {
|
|
|
941
1000
|
password: cmdOpts.password,
|
|
942
1001
|
passwordFile: cmdOpts.passwordFile,
|
|
943
1002
|
instruction: cmdOpts.instruction,
|
|
1003
|
+
testIdAttributes: cmdOpts.testIdAttributes !== undefined
|
|
1004
|
+
? parseTestIdAttributesFlag(cmdOpts.testIdAttributes, 'test-id-attributes')
|
|
1005
|
+
: undefined,
|
|
1006
|
+
clearTestIdAttributes: cmdOpts.clearTestIdAttributes,
|
|
944
1007
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
945
1008
|
}, deps);
|
|
946
1009
|
});
|
|
@@ -1192,6 +1255,12 @@ function renderProjectText(p) {
|
|
|
1192
1255
|
? `targetUrl: ${p.targetUrl}`
|
|
1193
1256
|
: `targetUrl: (not set — set one with: testsprite project update ${p.id} --url <url>)`);
|
|
1194
1257
|
}
|
|
1258
|
+
// Presence-keyed like targetUrl: older backends don't report the field at all.
|
|
1259
|
+
if ('testIdAttributes' in p) {
|
|
1260
|
+
lines.push(p.testIdAttributes && p.testIdAttributes.length > 0
|
|
1261
|
+
? `testIdAttrs: ${p.testIdAttributes.join(', ')} (locator priority, highest first)`
|
|
1262
|
+
: `testIdAttrs: (not set — engine default data-testid; set with: testsprite project update ${p.id} --test-id-attributes <list>)`);
|
|
1263
|
+
}
|
|
1195
1264
|
return lines.join('\n');
|
|
1196
1265
|
}
|
|
1197
1266
|
/**
|
|
@@ -1238,6 +1307,32 @@ function requireDocsProjectId(projectId, deps) {
|
|
|
1238
1307
|
return envValue;
|
|
1239
1308
|
throw localValidationError('--project <id> is required; pass --project <id> or set TESTSPRITE_PROJECT_ID');
|
|
1240
1309
|
}
|
|
1310
|
+
/**
|
|
1311
|
+
* A backend that predates the testIdAttributes field answers a PATCH/POST that
|
|
1312
|
+
* carries it with a generic 400 whose `details.accepted` list omits the field
|
|
1313
|
+
* ("at least one field must be provided …" — misleading, since a field WAS
|
|
1314
|
+
* provided). Translate that into an honest UNSUPPORTED so the user learns the
|
|
1315
|
+
* real cause instead of re-reading their own command.
|
|
1316
|
+
*/
|
|
1317
|
+
function translateUnsupportedTestIdAttributes(err, sentTestIdAttributes) {
|
|
1318
|
+
if (!sentTestIdAttributes || !(err instanceof ApiError) || err.code !== 'VALIDATION_ERROR')
|
|
1319
|
+
return err;
|
|
1320
|
+
const accepted = err.details?.accepted;
|
|
1321
|
+
if (!Array.isArray(accepted) || accepted.includes('testIdAttributes'))
|
|
1322
|
+
return err;
|
|
1323
|
+
return ApiError.fromEnvelope({
|
|
1324
|
+
error: {
|
|
1325
|
+
code: 'UNSUPPORTED',
|
|
1326
|
+
message: 'This backend does not support test-id attributes yet.',
|
|
1327
|
+
nextAction: 'The server accepted fields: ' +
|
|
1328
|
+
accepted.join(', ') +
|
|
1329
|
+
'. `--test-id-attributes` / `--clear-test-id-attributes` need a backend that knows the ' +
|
|
1330
|
+
'`testIdAttributes` field; retry once it is deployed, or drop the flag.',
|
|
1331
|
+
requestId: err.requestId,
|
|
1332
|
+
details: { reason: 'test_id_attributes_unsupported_backend', accepted },
|
|
1333
|
+
},
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1241
1336
|
function localValidationError(message) {
|
|
1242
1337
|
return ApiError.fromEnvelope({
|
|
1243
1338
|
error: {
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -745,7 +745,7 @@ export interface CliCreateFromPlanResponse extends CliCreateTestResponse {
|
|
|
745
745
|
* Caveat: the pinned tag only resolves once that version is actually
|
|
746
746
|
* released — a locally-built/pre-release checkout may see a 404 until then.
|
|
747
747
|
*/
|
|
748
|
-
export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.
|
|
748
|
+
export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.10.0/schemas/plan.schema.json";
|
|
749
749
|
/**
|
|
750
750
|
* The SINGLE canonical example plan. This
|
|
751
751
|
* exact value (via `PLAN_TEMPLATE_TEXT` below) is:
|
|
@@ -76,15 +76,16 @@ const me = {
|
|
|
76
76
|
seats: 1,
|
|
77
77
|
},
|
|
78
78
|
};
|
|
79
|
+
const checkoutProject = {
|
|
80
|
+
id: SAMPLE_PROJECT_ID,
|
|
81
|
+
name: 'Checkout',
|
|
82
|
+
type: 'frontend',
|
|
83
|
+
createdFrom: 'portal',
|
|
84
|
+
createdAt: '2026-04-15T10:23:00.000Z',
|
|
85
|
+
updatedAt: '2026-05-05T08:12:00.000Z',
|
|
86
|
+
};
|
|
79
87
|
const projects = [
|
|
80
|
-
|
|
81
|
-
id: SAMPLE_PROJECT_ID,
|
|
82
|
-
name: 'Checkout',
|
|
83
|
-
type: 'frontend',
|
|
84
|
-
createdFrom: 'portal',
|
|
85
|
-
createdAt: '2026-04-15T10:23:00.000Z',
|
|
86
|
-
updatedAt: '2026-05-05T08:12:00.000Z',
|
|
87
|
-
},
|
|
88
|
+
checkoutProject,
|
|
88
89
|
{
|
|
89
90
|
id: SAMPLE_PROJECT_ID_BACKEND,
|
|
90
91
|
name: 'Internal API',
|
|
@@ -533,7 +534,13 @@ const ENTRIES = [
|
|
|
533
534
|
docRole: 'API_DOC',
|
|
534
535
|
processStatus: 'Pending',
|
|
535
536
|
}),
|
|
536
|
-
|
|
537
|
+
// The single-project read carries the project-level test-id attribute list
|
|
538
|
+
// (present-and-null contract, see `CliProject.testIdAttributes`); the list
|
|
539
|
+
// row above deliberately omits it, like `targetUrl`.
|
|
540
|
+
entry('getProject', 'GET', '/projects/{projectId}', {
|
|
541
|
+
...checkoutProject,
|
|
542
|
+
testIdAttributes: ['data-element', 'data-testid'],
|
|
543
|
+
}),
|
|
537
544
|
// P6 — POST /projects (create project). The id uses a stable dry-run
|
|
538
545
|
// sentinel so agents can see a coherent field shape without a real key.
|
|
539
546
|
// Both `projectId` (the live field) and `id` (legacy/
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.10.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -67,6 +67,12 @@ Capture the returned `projectId`.
|
|
|
67
67
|
> `No environment URL configured` — the suite goes all-red. Always pass `--url`. If flows need
|
|
68
68
|
> login, pass `--username/--password-file` now so authenticated pages are reachable.
|
|
69
69
|
|
|
70
|
+
#### 2b. FE: register the app's test-hook attribute
|
|
71
|
+
|
|
72
|
+
If the source tags elements with something other than `data-testid` (e.g. `data-element`),
|
|
73
|
+
run `testsprite project update <projectId> --test-id-attributes data-element,data-testid`
|
|
74
|
+
once; exported locators then use the tag (check: `project get` → `testIdAttrs:`).
|
|
75
|
+
|
|
70
76
|
### 3. Get the tests — try generation first, author by hand if it isn't available
|
|
71
77
|
|
|
72
78
|
#### 3a. Preferred: generate → review → accept
|
|
@@ -261,7 +261,11 @@ confidently-wrong `passed` (bare visibility assertions) or a thrashing
|
|
|
261
261
|
- **Describe outcomes, not selectors.** The testing agent locates targets
|
|
262
262
|
semantically — describe the intent and the match stays robust across copy
|
|
263
263
|
changes; a guessed literal label defeats that. E.g. write `"Submit the form"`,
|
|
264
|
-
not `"Click the blue 'Submit' button"`.
|
|
264
|
+
not `"Click the blue 'Submit' button"`. If the app tags elements with its own
|
|
265
|
+
attribute (`data-element`, `data-cy`, …), make sure the project knows —
|
|
266
|
+
`testsprite project get <projectId>` shows `testIdAttrs:`; set it once with
|
|
267
|
+
`project update <projectId> --test-id-attributes <attr>,data-testid` — and the
|
|
268
|
+
exported code will locate tagged elements by that attribute instead of text.
|
|
265
269
|
- **`Navigate to` only on step 1** (or a login page). Use clicks for every later
|
|
266
270
|
transition — direct URLs break SPA routing.
|
|
267
271
|
- **FE plans narrate a user journey through their actions.** Each action is
|