@testsprite/testsprite-cli 0.15.0 → 0.16.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.
Files changed (38) hide show
  1. package/README.md +24 -16
  2. package/dist/commands/agent.js +7 -2
  3. package/dist/commands/auth.js +7 -3
  4. package/dist/commands/ci.js +20 -18
  5. package/dist/commands/completion.js +2 -1
  6. package/dist/commands/doctor.js +2 -1
  7. package/dist/commands/init.js +8 -2
  8. package/dist/commands/project-env.js +39 -17
  9. package/dist/commands/project-sign-in.js +9 -4
  10. package/dist/commands/project.js +28 -21
  11. package/dist/commands/schedule.js +24 -15
  12. package/dist/commands/test.d.ts +32 -26
  13. package/dist/commands/test.js +949 -769
  14. package/dist/commands/testlist.js +13 -3
  15. package/dist/commands/tunnel.js +23 -25
  16. package/dist/commands/usage.js +1 -0
  17. package/dist/index.js +9 -6
  18. package/dist/lib/conflict-reason.d.ts +24 -3
  19. package/dist/lib/conflict-reason.js +33 -2
  20. package/dist/lib/deprecate.d.ts +22 -0
  21. package/dist/lib/deprecate.js +26 -0
  22. package/dist/lib/dry-run/samples.js +14 -4
  23. package/dist/lib/environment-tunnel.d.ts +2 -1
  24. package/dist/lib/environment-tunnel.js +1 -4
  25. package/dist/lib/http.js +20 -2
  26. package/dist/lib/junit-report.d.ts +3 -0
  27. package/dist/lib/junit-report.js +8 -1
  28. package/dist/lib/output.d.ts +11 -1
  29. package/dist/lib/output.js +17 -2
  30. package/dist/lib/response-schemas.js +3 -0
  31. package/dist/lib/runs.types.d.ts +16 -0
  32. package/dist/lib/telemetry.d.ts +1 -1
  33. package/dist/lib/telemetry.js +2 -0
  34. package/dist/version.d.ts +1 -1
  35. package/dist/version.js +1 -1
  36. package/package.json +3 -3
  37. package/skills/testsprite-verify.codex.md +7 -7
  38. package/skills/testsprite-verify.skill.md +24 -21
@@ -910,7 +910,17 @@ export function createTestListCommand(deps = {}) {
910
910
  });
911
911
  testlist
912
912
  .command('run <list-id>')
913
- .description('Run a test list (dispatch its cases and return pollable run ids). Loopback environments open a tunnel automatically and wait.')
913
+ .summary('Run a test list')
914
+ .description("Run a test list (dispatch its cases and return pollable run ids). Environments come from the list's --project-env mapping; loopback ones open one tunnel and wait (backend cases are skipped).\n" +
915
+ '\nExit codes:\n' +
916
+ ' 0 dispatched (or all passed with --wait)\n' +
917
+ ' 1 a run failed / blocked / cancelled\n' +
918
+ ' 3 auth error\n' +
919
+ ' 4 a --case id is not in the list\n' +
920
+ ' 6 nothing dispatched: every case conflicted (already running, or cannot run here)\n' +
921
+ ' 7 timeout, or some cases were rate-deferred (retry the printed ids)\n' +
922
+ ' 12 insufficient credits (non-retriable; top up)\n' +
923
+ ' 13 feature gated / workspace paused')
914
924
  .option('--case <test-id>', 'run only this case (repeatable; default: every case in the list)', collectRepeatable, [])
915
925
  .option('--wait', 'poll every dispatched run until terminal or --timeout', false)
916
926
  .option('--no-wait', 'detach without opening an automatic environment tunnel')
@@ -921,8 +931,8 @@ export function createTestListCommand(deps = {}) {
921
931
  .option('--report <format>', 'with --wait: write a JUnit XML sidecar after polling (accepted: junit)')
922
932
  .option('--report-file <path>', 'output path for --report (atomic write)')
923
933
  .option('--report-suite-name <name>', 'JUnit <testsuite name=...> override (default: testsprite:testlist:<listId>)')
924
- .option('--gh-output', 'with --wait: emit GitHub-native output (::error:: annotations for failed/timed-out members, ::warning:: for never-dispatched ones; job-summary table when $GITHUB_STEP_SUMMARY is set). Auto-enabled when GITHUB_ACTIONS=true')
925
- .option('--summary-file <path>', 'with --wait: also write the reduced machine summary JSON {total, passed, failed, skipped, timedOut, runs[]} to this file')
934
+ .option('--gh-output', 'with --wait: emit GitHub annotations (::error:: failed/timed-out, ::warning:: never dispatched) and a job-summary table when $GITHUB_STEP_SUMMARY is set; auto-enabled when GITHUB_ACTIONS=true')
935
+ .option('--summary-file <path>', 'with --wait: also write summary JSON {total, passed, failed, skipped, timedOut, runs[]} to this file')
926
936
  .addHelpText('after', GLOBAL_OPTS_HINT)
927
937
  .action(async (listId, cmdOpts, command) => {
928
938
  const wait = cmdOpts.wait === true;
@@ -35,8 +35,8 @@ function assertTunnelClientId(clientId) {
35
35
  throw ApiError.fromEnvelope({
36
36
  error: {
37
37
  code: 'VALIDATION_ERROR',
38
- message: "Tunnel client id must be a UUID (see 'testsprite tunnel status'/'tunnel start' output).",
39
- nextAction: "Run 'testsprite tunnel start' to get a tunnel client id.",
38
+ message: "Tunnel client id must be a UUID (see 'testsprite tunnel list').",
39
+ nextAction: "Run 'testsprite tunnel list' to see your tunnel client ids, or 'testsprite tunnel start' to open one.",
40
40
  requestId: 'local',
41
41
  details: { field: 'clientId', reason: 'must be a UUID' },
42
42
  },
@@ -551,18 +551,14 @@ export async function runTunnelStop(opts, deps = {}) {
551
551
  export function createTunnelCommand(deps = {}) {
552
552
  const tunnel = new Command('tunnel')
553
553
  .description('Open a tunnel so TestSprite can reach an app on this machine')
554
- .addHelpText('after', '\nFrontend runs automatically open and close a tunnel when the selected environment URL\n' +
555
- 'is on this machine. Use these commands when you want one tunnel to serve several runs, or to check on\n' +
556
- 'one that a run reported as down.\n' +
557
- '\nA tunnel lives only as long as `tunnel start` is running — there is no background\n' +
558
- 'daemon, because the credential that authorises an inbound network path into this machine\n' +
559
- 'is never written to disk.\n' +
554
+ .addHelpText('after', '\nFrontend runs open and close a tunnel automatically when the environment URL is on this\n' +
555
+ 'machine. Use these commands to share one tunnel across several runs or to check one a run\n' +
556
+ 'reported as down. A tunnel lives only as long as `tunnel start` runs: there is no background\n' +
557
+ 'daemon, because its credential is never written to disk.\n' +
560
558
  '\nExamples:\n' +
561
- ' testsprite tunnel start # hold a tunnel open (Ctrl-C to stop)\n' +
562
- ' testsprite test run <id> --env <name> --tunnel-client <id>\n' +
563
- ' testsprite tunnel list\n' +
564
- ' testsprite tunnel status <id>\n' +
565
- ' testsprite tunnel stop <id>\n' +
559
+ ' testsprite tunnel start # hold a tunnel open (Ctrl-C to stop)\n' +
560
+ ' testsprite test run <test-id> --env <name> --tunnel-client <client-id>\n' +
561
+ ' testsprite test run <test-id> --local 3000 --tunnel-client <client-id>\n' +
566
562
  ' testsprite tunnel stop --all --confirm\n');
567
563
  tunnel
568
564
  .command('start')
@@ -570,14 +566,13 @@ export function createTunnelCommand(deps = {}) {
570
566
  // where an embedded newline breaks out of the indented column. The detail
571
567
  // belongs in this command's own help, below.
572
568
  .description('Open a tunnel and hold it until you stop the command (Ctrl-C)')
573
- .option('--ttl <seconds>', 'requested lifetime of the tunnel credential (60–28800). The server clamps this, and the ' +
574
- 'credential is deleted when the command exits regardless — the lifetime only matters if ' +
575
- 'this process is killed without cleaning up.')
576
- .addHelpText('after', '\nPrints the client id to stderr as soon as it is minted, before connecting; pass it\n' +
577
- 'to `test run <id> --env <name> --tunnel-client <id>` for an environment on this machine.\n' +
578
- 'Frontend runs normally open their own tunnel automatically for a loopback environment URL.\n' +
579
- '\nDev servers can take a minute per page through the tunnel. For a heavy dev server,\n' +
580
- "test a built server: `npm run build`, then your framework's preview/start command.\n" +
569
+ .summary('Open a tunnel and hold it until Ctrl-C')
570
+ .option('--ttl <seconds>', 'requested credential lifetime (60–28800), clamped by the server; the credential is deleted ' +
571
+ 'on exit regardless, so this only matters if the process is killed')
572
+ .addHelpText('after', '\nPrints the client id to stderr as soon as it is minted; pass it to\n' +
573
+ '`test run <test-id> --env <name> --tunnel-client <client-id>` for an environment on this machine.\n' +
574
+ '\nDev servers can take a minute per page through the tunnel; for a heavy one, test a built\n' +
575
+ "server (`npm run build`, then your framework's preview/start command).\n" +
581
576
  '\nExit codes:\n' +
582
577
  ' 0 you stopped it (Ctrl-C is the normal way to end this command)\n' +
583
578
  ' 3 auth error — the key needs the `run:tunnel` scope; mint a new key\n' +
@@ -594,8 +589,7 @@ export function createTunnelCommand(deps = {}) {
594
589
  tunnel
595
590
  .command('list')
596
591
  .description('List live tunnel bindings for this account')
597
- .addHelpText('after', '\nShows each tunnel client id, connection status, creation time and expiry.\n' +
598
- 'Includes tunnels automatically opened for environments on this machine.\n' +
592
+ .addHelpText('after', '\nShows each tunnel client id, status, creation time and expiry, including tunnels opened automatically.\n' +
599
593
  '\nExit codes:\n' +
600
594
  ' 0 listed (possibly empty)\n' +
601
595
  ' 3 auth error — the key needs the `run:tunnel` scope\n' +
@@ -607,6 +601,7 @@ export function createTunnelCommand(deps = {}) {
607
601
  });
608
602
  tunnel
609
603
  .command('status <client-id>')
604
+ .summary('Report whether a tunnel client is connected')
610
605
  .description('Report whether a tunnel client of yours is connected')
611
606
  .addHelpText('after', '\n`offline` means the API answered and said nothing is connected with that id. A failure\n' +
612
607
  'to reach TestSprite is reported as its own error, never as `offline`.\n' +
@@ -614,6 +609,7 @@ export function createTunnelCommand(deps = {}) {
614
609
  '\nExit codes:\n' +
615
610
  ' 0 answered (the answer may be `offline`)\n' +
616
611
  ' 4 no such tunnel for this account\n' +
612
+ ' 5 client id is not a UUID\n' +
617
613
  ' 10 could not reach TestSprite to ask\n')
618
614
  .addHelpText('after', GLOBAL_OPTS_HINT)
619
615
  .action(async (clientId, _cmdOpts, command) => {
@@ -621,19 +617,21 @@ export function createTunnelCommand(deps = {}) {
621
617
  });
622
618
  tunnel
623
619
  .command('stop [client-id]')
620
+ .summary('Stop one tunnel, or all with --all')
624
621
  .description('Destroy one tunnel credential or stop every live tunnel')
625
622
  .option('--all', 'stop every live tunnel on this account', false)
626
623
  .option('--confirm', 'required with --all for this destructive operation', false)
627
624
  .addHelpText('after', '\nStopping one that is already gone succeeds. Revoking the credential\n' +
628
625
  'also makes a running `tunnel start` exit within ~15 s.\n' +
629
626
  'A run that automatically opened this tunnel loses access to its environment when you stop it.\n' +
630
- 'Stopping all requires --confirm; --dry-run previews sample ids without it.\n' +
627
+ 'Stopping all requires --confirm and also revokes tunnels used by other terminals and CI jobs;\n' +
628
+ '--dry-run previews sample ids without it.\n' +
631
629
  '\nExit codes:\n' +
632
630
  ' 0 stopped (or already absent), including an empty --all result\n' +
633
631
  ' 1 at least one tunnel could not be stopped\n' +
634
632
  ' 3 auth error — the key needs the `run:tunnel` scope\n' +
635
633
  ' 4 server too old to list tunnels (with --all)\n' +
636
- ' 5 invalid arguments or --all without --confirm\n' +
634
+ ' 5 invalid arguments (e.g. a client id that is not a UUID) or --all without --confirm\n' +
637
635
  ' 10 could not reach TestSprite\n')
638
636
  .addHelpText('after', GLOBAL_OPTS_HINT)
639
637
  .action(async (clientId, cmdOpts, command) => {
@@ -241,6 +241,7 @@ function renderUsage(u, portalBase) {
241
241
  export function createUsageCommand(deps = {}) {
242
242
  const cmd = new Command('usage')
243
243
  .alias('credits')
244
+ .summary('Show credit balance and plan info')
244
245
  .description('Show credit balance and plan/entitlement info (proactive pre-flight before a large test run)')
245
246
  .addHelpText('after', GLOBAL_OPTS_HINT)
246
247
  .addHelpText('after', '\nExamples:\n' +
package/dist/index.js CHANGED
@@ -40,13 +40,12 @@ program
40
40
  .version(VERSION)
41
41
  .option('--output <mode>', 'Output format (json|text)', 'text')
42
42
  .option('--profile <name>', 'Configuration profile to use')
43
- .option('--endpoint-url <url>', 'Override the API endpoint host')
44
- .option('--verbose', 'Emit human-readable HTTP retry / backoff / polling-mode transitions to stderr. Less noisy than --debug; useful for diagnosing hangs without the full trace.')
43
+ .option('--endpoint-url <url>', 'API base URL (a full http(s) URL)')
44
+ .option('--verbose', 'Log HTTP retry / backoff / polling transitions to stderr (lighter than --debug)')
45
45
  .option('--debug', 'Print HTTP method/path, request id, latency, retry decisions to stderr')
46
- .option('--dry-run', 'Skip the network and credentials; emit a canned sample matching the OpenAPI contract. Useful for learning the CLI surface without an API key. Note: file inputs you pass (--plan-from/--plans/--steps) are still read and validated locally; only --code-file uses a placeholder.')
47
- .option('--request-timeout <seconds>', 'Client-side per-request timeout in seconds (default: 120). Aborts any single fetch that does not complete within this deadline. ' +
48
- 'Override via TESTSPRITE_REQUEST_TIMEOUT_MS env var (milliseconds). ' +
49
- 'Range: 1–600. Does not affect the --timeout polling ceiling for `test run/wait`.');
46
+ .option('--dry-run', 'Skip the network and credentials; emit a canned sample matching the OpenAPI contract. Exception: run commands (`test run`, `test rerun`, `test create --run`, `testlist run`) with credentials and no explicit target may make read-only GETs to preview an automatic tunnel target; nothing is created or started. File inputs (--plan-from/--plans/--steps) are still read locally; --code-file uses a placeholder.')
47
+ .option('--request-timeout <seconds>', 'Per-request timeout in seconds (default 120; range 1–600, values outside are clamped). ' +
48
+ 'Does not affect the --timeout polling ceiling for `test run/wait`.');
50
49
  // `setup` is the primary onboarding command, listed FIRST in --help so a coding
51
50
  // agent reaches it before anything else. `init` is kept as a hidden, deprecated
52
51
  // alias (invisible to --help; still works for existing scripts/agents).
@@ -165,6 +164,10 @@ function unknownRootCommandMaskedByHelp(args) {
165
164
  return undefined;
166
165
  return args.slice(1).some(arg => arg === '--help' || arg === '-h') ? first : undefined;
167
166
  }
167
+ program.addHelpText('after', '\nEnvironment:\n' +
168
+ ' TESTSPRITE_API_KEY (overrides stored credentials), TESTSPRITE_NO_UPDATE_NOTIFIER (disables\n' +
169
+ ' the version check); TESTSPRITE_API_URL, TESTSPRITE_PROFILE and TESTSPRITE_REQUEST_TIMEOUT_MS\n' +
170
+ ' (milliseconds) mirror --endpoint-url, --profile and --request-timeout.');
168
171
  program.addHelpText('beforeAll', context => {
169
172
  if (context.command !== program)
170
173
  return '';
@@ -17,10 +17,19 @@
17
17
  import { ApiError } from './errors.js';
18
18
  export type ConflictReason = 'in_flight' | 'mcp_view_only' | 'local_address' | 'not_found' | 'insufficient_credits' | 'paused'
19
19
  /** Deprecated spelling of `paused`, still sent by older backends. */
20
- | 'billing_hold' | 'error';
20
+ | 'billing_hold'
21
+ /**
22
+ * A backend consumer needs a variable no test case in the project captures.
23
+ * Like `producer_in_flight`, its `currentRunId` is the result the server
24
+ * seeded BLOCKED for this request, which becomes the test case's latest
25
+ * status: never dispatched, never charged.
26
+ */
27
+ | 'no_producer'
28
+ /** A backend consumer whose producer is running in another run. */
29
+ | 'producer_in_flight' | 'error';
21
30
  /** A conflict entry on a run response. `message` carries actionable detail for
22
- * `local_address` / `insufficient_credits` / `paused` / `error` (the
23
- * backend's nextAction). */
31
+ * `local_address` / `insufficient_credits` / `paused` / `no_producer` /
32
+ * `producer_in_flight` / `error` (the backend's nextAction). */
24
33
  export interface RunConflict {
25
34
  testId: string;
26
35
  currentRunId?: string;
@@ -42,6 +51,18 @@ export declare function describeConflict(c: RunConflict): string;
42
51
  * reason-aware summary instead of a misleading blanket "in flight".
43
52
  */
44
53
  export declare function allConflictsInFlight(conflicts: readonly RunConflict[]): boolean;
54
+ /**
55
+ * A backend consumer blocked before dispatch on a missing or busy producer.
56
+ * The CLI reports it as a refusal (exit 6), as a single `test run` does,
57
+ * rather than polling the result the server seeded for it.
58
+ */
59
+ export declare function isProducerBlock(c: RunConflict): boolean;
60
+ /**
61
+ * The retry advice for a set of refused test cases. A `no_producer` test case
62
+ * needs a producer, not a wait, so it gets its own line; every other reason
63
+ * keeps the caller's wait hint, given the ids it applies to.
64
+ */
65
+ export declare function conflictNextAction(conflicts: readonly RunConflict[], waitHint: (ids: readonly string[]) => string): string;
45
66
  /**
46
67
  * One-line summary of a conflict set grouped by reason, e.g.
47
68
  * `2 already in flight, 1 environment not runnable`. Used where a single line
@@ -34,6 +34,10 @@ export function describeConflict(c) {
34
34
  case 'paused':
35
35
  case 'billing_hold':
36
36
  return c.message || 'workspace paused';
37
+ case 'no_producer':
38
+ return c.message || 'no test case captures a variable it needs';
39
+ case 'producer_in_flight':
40
+ return c.message || 'its producer is running in another run';
37
41
  case 'error':
38
42
  return c.message || 'dispatch failed';
39
43
  case 'in_flight':
@@ -49,6 +53,8 @@ const CONFLICT_LABELS = {
49
53
  insufficient_credits: 'insufficient credits',
50
54
  paused: 'workspace paused',
51
55
  billing_hold: 'workspace paused',
56
+ no_producer: 'no producer for its variables',
57
+ producer_in_flight: 'producer running in another run',
52
58
  error: 'dispatch error',
53
59
  };
54
60
  /**
@@ -71,6 +77,30 @@ function countByReason(conflicts) {
71
77
  }
72
78
  return counts;
73
79
  }
80
+ /**
81
+ * A backend consumer blocked before dispatch on a missing or busy producer.
82
+ * The CLI reports it as a refusal (exit 6), as a single `test run` does,
83
+ * rather than polling the result the server seeded for it.
84
+ */
85
+ export function isProducerBlock(c) {
86
+ return c.reason === 'no_producer' || c.reason === 'producer_in_flight';
87
+ }
88
+ /**
89
+ * The retry advice for a set of refused test cases. A `no_producer` test case
90
+ * needs a producer, not a wait, so it gets its own line; every other reason
91
+ * keeps the caller's wait hint, given the ids it applies to.
92
+ */
93
+ export function conflictNextAction(conflicts, waitHint) {
94
+ const missing = conflicts.filter(c => c.reason === 'no_producer').map(c => c.testId);
95
+ const waiting = conflicts.filter(c => c.reason !== 'no_producer').map(c => c.testId);
96
+ const lines = [
97
+ waiting.length > 0 ? waitHint(waiting) : '',
98
+ missing.length > 0
99
+ ? `Add or accept a test case that captures the missing variable (or supply it from the environment), then retry: ${missing.join(' ')}`
100
+ : '',
101
+ ];
102
+ return lines.filter(Boolean).join('\n');
103
+ }
74
104
  /**
75
105
  * One-line summary of a conflict set grouped by reason, e.g.
76
106
  * `2 already in flight, 1 environment not runnable`. Used where a single line
@@ -78,9 +108,10 @@ function countByReason(conflicts) {
78
108
  */
79
109
  export function summarizeConflicts(conflicts) {
80
110
  // A future/unknown reason the loose wire schema admits (describeConflict covers
81
- // it via its default arm) must not render as "N undefined" here.
111
+ // it via its default arm) must not render as "N undefined" here. Callers wrap
112
+ // this in "not dispatched (…)", so the fallback must not say that again.
82
113
  return [...countByReason(conflicts).entries()]
83
- .map(([reason, n]) => `${n} ${CONFLICT_LABELS[reason] ?? 'not dispatched'}`)
114
+ .map(([reason, n]) => `${n} ${CONFLICT_LABELS[reason] ?? 'other'}`)
84
115
  .join(', ');
85
116
  }
86
117
  /**
@@ -8,3 +8,25 @@
8
8
  * stderr — stdout stays clean so JSON pipelines are unaffected.
9
9
  */
10
10
  export declare function emitDeprecationNotice(oldCmd: string, newCmd: string, stderr?: (line: string) => void): void;
11
+ /** Release that deletes the commands deprecated in the 0.16 line. */
12
+ export declare const REMOVED_IN = "0.17.0";
13
+ /**
14
+ * A deprecated command and the invocation that replaces it. `command` is the
15
+ * full name (`test rerun`) so the same entry feeds the stderr notice and the
16
+ * JSON `deprecations` key. `replacement` is a template, not a command to run
17
+ * as is: the caller's ids and flags carry over (see the notice's advice).
18
+ */
19
+ export interface DeprecationEntry {
20
+ command: string;
21
+ replacement: string;
22
+ removedIn: string;
23
+ }
24
+ export declare const TEST_RERUN_DEPRECATION: DeprecationEntry;
25
+ export declare const TEST_FLAKY_DEPRECATION: DeprecationEntry;
26
+ /**
27
+ * `advice` replaces the default "Use `<replacement>`." sentence with command-specific
28
+ * migration steps. `noReplacement` says so in the lead sentence for a command that is
29
+ * deleted outright.
30
+ */
31
+ export declare function deprecationNoticeLine(entry: DeprecationEntry, advice?: string, noReplacement?: boolean): string;
32
+ export declare function emitDeprecationEntry(entry: DeprecationEntry, stderr?: (line: string) => void, advice?: string, noReplacement?: boolean): void;
@@ -10,4 +10,30 @@
10
10
  export function emitDeprecationNotice(oldCmd, newCmd, stderr = (line) => process.stderr.write(`${line}\n`)) {
11
11
  stderr(`[deprecated] \`testsprite ${oldCmd}\` is deprecated — use \`testsprite ${newCmd}\`.`);
12
12
  }
13
+ /** Release that deletes the commands deprecated in the 0.16 line. */
14
+ export const REMOVED_IN = '0.17.0';
15
+ export const TEST_RERUN_DEPRECATION = {
16
+ command: 'test rerun',
17
+ replacement: 'test run',
18
+ removedIn: REMOVED_IN,
19
+ };
20
+ // `test flaky` has no replacement; `replacement` names the command that samples a test again.
21
+ export const TEST_FLAKY_DEPRECATION = {
22
+ command: 'test flaky',
23
+ replacement: 'test run',
24
+ removedIn: REMOVED_IN,
25
+ };
26
+ /**
27
+ * `advice` replaces the default "Use `<replacement>`." sentence with command-specific
28
+ * migration steps. `noReplacement` says so in the lead sentence for a command that is
29
+ * deleted outright.
30
+ */
31
+ export function deprecationNoticeLine(entry, advice, noReplacement = false) {
32
+ return (`[deprecated] \`testsprite ${entry.command}\` is deprecated and will be removed in ${entry.removedIn}` +
33
+ (noReplacement ? ', with no replacement. ' : '. ') +
34
+ (advice ?? `Use \`testsprite ${entry.replacement}\`.`));
35
+ }
36
+ export function emitDeprecationEntry(entry, stderr = (line) => process.stderr.write(`${line}\n`), advice, noReplacement = false) {
37
+ stderr(deprecationNoticeLine(entry, advice, noReplacement));
38
+ }
13
39
  //# sourceMappingURL=deprecate.js.map
@@ -891,13 +891,14 @@ const ENTRIES = [
891
891
  // **MUST appear before `/tests` and `/tests/{testId}` generic matchers**
892
892
  // so the more-specific runs path wins. Canned response shape per the
893
893
  // runs-trigger design spec.
894
- entry('triggerRun', 'POST', '/tests/{testId}/runs', {
894
+ entry('triggerRun', 'POST', '/tests/{testId}/runs', (req) => ({
895
895
  runId: SAMPLE_RUN_ID,
896
896
  status: 'queued',
897
897
  enqueuedAt: '2026-05-15T19:32:00.000Z',
898
898
  codeVersion: 'v1',
899
899
  targetUrl: SAMPLE_TARGET_URL,
900
- }),
900
+ ...echoSkipDependencies(req),
901
+ })),
901
902
  // M3.4 piece-3 — POST /tests/{testId}/runs/rerun (single rerun).
902
903
  // **MUST appear before `/tests/{testId}/runs` and `/tests/{testId}`** so the
903
904
  // more-specific `/runs/rerun` path wins over the generic runs trigger.
@@ -928,7 +929,7 @@ const ENTRIES = [
928
929
  // **MUST appear before `/tests/batch/rerun` and `/tests/batch` (create)**
929
930
  // so the more-specific `/batch/run` path wins. Shows `accepted[]` with
930
931
  // per-test runIds + `skippedFrontend[]` so dry-run learners see both shapes.
931
- entry('triggerBatchRunFresh', 'POST', '/tests/batch/run', {
932
+ entry('triggerBatchRunFresh', 'POST', '/tests/batch/run', (req) => ({
932
933
  accepted: [
933
934
  {
934
935
  testId: SAMPLE_TEST_ID_FRESH_1,
@@ -945,7 +946,8 @@ const ENTRIES = [
945
946
  deferred: [],
946
947
  skippedFrontend: [],
947
948
  skippedIntegration: [],
948
- }),
949
+ ...echoSkipDependencies(req),
950
+ })),
949
951
  // M3.4 piece-3 — POST /tests/batch/rerun (batch rerun).
950
952
  // **MUST appear before `/tests/batch` (create)** so the more-specific
951
953
  // `/batch/rerun` path wins. Shows `accepted[]` with per-test runIds (C2)
@@ -1066,6 +1068,14 @@ const ENTRIES = [
1066
1068
  expiresAt: '2026-01-01T01:00:00.000Z',
1067
1069
  }),
1068
1070
  ];
1071
+ /** What a backend that handles the field answers: `true` when asked, otherwise the key is omitted. */
1072
+ function echoSkipDependencies(req) {
1073
+ return req != null &&
1074
+ typeof req === 'object' &&
1075
+ req.skipDependencies === true
1076
+ ? { skipDependencies: true }
1077
+ : {};
1078
+ }
1069
1079
  function entry(operationId, method, pathTemplate, body) {
1070
1080
  const bodyFn = typeof body === 'function' ? body : () => body;
1071
1081
  return {
@@ -4,6 +4,7 @@ import { openTunnelSession, type TunnelClientHandle } from './tunnel-session.js'
4
4
  import { type TunnelClientOptions } from '../vendor/tunnel-client/index.js';
5
5
  import type { HttpClient } from './http.js';
6
6
  import type { RunResponse } from './runs.types.js';
7
+ import type { DeprecationEntry } from './deprecate.js';
7
8
  import { ApiError } from './errors.js';
8
9
  import { type LoopbackHost, type StoredLocalTarget } from './local-target.js';
9
10
  export interface RunTargetTest {
@@ -28,7 +29,6 @@ export declare function assertNoTunnelOptions(args: {
28
29
  tunnelClientId?: string;
29
30
  cancelOnInterrupt?: boolean;
30
31
  }): void;
31
- export declare function severalIdsWithoutTunnel(): never;
32
32
  /** One resolver for fresh runs, replay, chained creation and test-list runs. */
33
33
  export declare function resolveEnvironmentRunTarget(args: {
34
34
  client: Pick<HttpClient, 'get'>;
@@ -105,5 +105,6 @@ export declare function emitEnvironmentDispatchPartial(responses: Array<{
105
105
  summaryFile?: string;
106
106
  }, deps: ClientFactoryDeps & {
107
107
  stdout?: (line: string) => void;
108
+ deprecations?: readonly DeprecationEntry[];
108
109
  }, label: string, error: unknown, context: EnvironmentTunnelContext): Promise<void>;
109
110
  export {};
@@ -27,9 +27,6 @@ export function assertNoTunnelOptions(args) {
27
27
  'cancelled when this command stops waiting — Ctrl-C detaches, and `testsprite test ' +
28
28
  'cancel <run-id>` is the way to stop one');
29
29
  }
30
- export function severalIdsWithoutTunnel() {
31
- throw localValidationError('test-id', 'several test ids run through one tunnel with --local <port>. For tests the runner can already reach, use `testsprite test run --all --project <id> [--filter <text>]`, or run them one at a time.');
32
- }
33
30
  const announcedEnvironments = new WeakMap();
34
31
  /** One resolver for fresh runs, replay, chained creation and test-list runs. */
35
32
  export async function resolveEnvironmentRunTarget(args) {
@@ -430,7 +427,7 @@ export async function emitEnvironmentDispatchPartial(responses, testIds, opts, d
430
427
  ...(responses.some(response => response.notFound) ? { notFound } : {}),
431
428
  };
432
429
  const stderr = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
433
- new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr }).print(partial, () => accepted.map(row => `${row.runId} ${row.status}`).join('\n'));
430
+ new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr }, { deprecations: deps.deprecations }).print(partial, () => accepted.map(row => `${row.runId} ${row.status}`).join('\n'));
434
431
  const summary = summarizeAcceptedPayload(JSON.stringify(partial));
435
432
  summary.runs.push(...notRunTestIds.map(testId => ({
436
433
  testId,
package/dist/lib/http.js CHANGED
@@ -221,7 +221,7 @@ export class HttpClient {
221
221
  signal: options.signal,
222
222
  schema: RERUN_RESPONSE_SCHEMA,
223
223
  retryOnConflict: false,
224
- }).then(r => r.body);
224
+ }).then(r => withoutDeprecationAdvisories(r.body));
225
225
  }
226
226
  /**
227
227
  * POST /api/cli/v1/tests/batch/rerun
@@ -237,7 +237,7 @@ export class HttpClient {
237
237
  signal: options.signal,
238
238
  schema: BATCH_RERUN_RESPONSE_SCHEMA,
239
239
  retryOnConflict: false,
240
- }).then(r => r.body);
240
+ }).then(r => withoutDeprecationAdvisories(r.body));
241
241
  }
242
242
  /**
243
243
  * POST /api/cli/v1/tests/batch/run
@@ -1244,4 +1244,22 @@ function isTimeoutError(err) {
1244
1244
  }
1245
1245
  return false;
1246
1246
  }
1247
+ /**
1248
+ * Drop server-sent `feature: 'deprecation'` advisories from a rerun response.
1249
+ * The CLI owns the deprecation signal itself (one stderr line plus the JSON
1250
+ * `deprecations` key), so passing the server's through would announce the same
1251
+ * thing twice. Matched on the machine-readable `feature`, never on message
1252
+ * text; other advisories (autoHeal) are kept and an emptied list is removed.
1253
+ */
1254
+ function withoutDeprecationAdvisories(body) {
1255
+ if (!body.advisories)
1256
+ return body;
1257
+ const kept = body.advisories.filter(a => a.feature !== 'deprecation');
1258
+ if (kept.length === body.advisories.length)
1259
+ return body;
1260
+ const next = { ...body, advisories: kept };
1261
+ if (kept.length === 0)
1262
+ delete next.advisories;
1263
+ return next;
1264
+ }
1247
1265
  //# sourceMappingURL=http.js.map
@@ -7,6 +7,8 @@ export interface JUnitTestResult {
7
7
  status: string;
8
8
  /** Observed on polled runs; used for classname when --project is omitted. */
9
9
  projectId?: string;
10
+ /** This row's own `classname`, when the batch spans several projects. */
11
+ classname?: string;
10
12
  error?: {
11
13
  code: string;
12
14
  message: string;
@@ -61,6 +63,7 @@ export declare function assertJUnitReportOptions(opts: JUnitReportFlagOptions):
61
63
  */
62
64
  export declare function resolveBatchReportProjectId(opts: {
63
65
  projectId?: string;
66
+ projectIdByTestId?: ReadonlyMap<string, string>;
64
67
  }, results: ReadonlyArray<{
65
68
  projectId?: string;
66
69
  }>): string;
@@ -68,9 +68,16 @@ export function assertJUnitReportOptions(opts) {
68
68
  export function resolveBatchReportProjectId(opts, results) {
69
69
  if (opts.projectId)
70
70
  return opts.projectId;
71
+ // Explicit ids that span several projects have no single `--project`; each
72
+ // row carries its own project as its classname and the suite gets this token.
73
+ const known = new Set(opts.projectIdByTestId?.values());
74
+ if (known.size > 1)
75
+ return 'multiple-projects';
71
76
  const fromPoll = results.map(r => r.projectId).find((id) => !!id);
72
77
  if (fromPoll)
73
78
  return fromPoll;
79
+ if (known.size === 1)
80
+ return [...known][0];
74
81
  throw localValidationError('project', '--report junit requires --project <id> when the project cannot be inferred from run results');
75
82
  }
76
83
  /**
@@ -168,7 +175,7 @@ export function buildJUnitReport(opts) {
168
175
  }
169
176
  }
170
177
  const suiteName = escapeXml(opts.suiteName);
171
- const testcases = results.map(r => renderTestcase(r, opts.classname)).join('\n');
178
+ const testcases = results.map(r => renderTestcase(r, r.classname ?? opts.classname)).join('\n');
172
179
  return [
173
180
  XML_DECL,
174
181
  '<testsuites>',
@@ -1,3 +1,4 @@
1
+ import type { DeprecationEntry } from './deprecate.js';
1
2
  export type OutputMode = 'json' | 'text';
2
3
  /**
3
4
  * Help-text footer pointing at the global options surface so users
@@ -72,7 +73,16 @@ export declare class Output {
72
73
  private readonly stdoutWrite;
73
74
  private readonly stderrWrite;
74
75
  private readonly rawStdoutWrite;
75
- constructor(mode?: OutputMode, streams?: OutputStreams);
76
+ private readonly deprecations;
77
+ /**
78
+ * `options.deprecations` is appended as the LAST key of a JSON object
79
+ * payload from `print` (text mode, arrays and error envelopes are never
80
+ * touched), so a deprecated command's output stays the same document plus
81
+ * one trailing key.
82
+ */
83
+ constructor(mode?: OutputMode, streams?: OutputStreams, options?: {
84
+ deprecations?: readonly DeprecationEntry[];
85
+ });
76
86
  print(data: unknown, textRenderer?: (data: unknown) => string): void;
77
87
  /**
78
88
  * Write a chunk of bytes to stdout verbatim. Awaits any
@@ -36,8 +36,16 @@ export class Output {
36
36
  stdoutWrite;
37
37
  stderrWrite;
38
38
  rawStdoutWrite;
39
- constructor(mode = 'text', streams = {}) {
39
+ deprecations;
40
+ /**
41
+ * `options.deprecations` is appended as the LAST key of a JSON object
42
+ * payload from `print` (text mode, arrays and error envelopes are never
43
+ * touched), so a deprecated command's output stays the same document plus
44
+ * one trailing key.
45
+ */
46
+ constructor(mode = 'text', streams = {}, options = {}) {
40
47
  this.mode = mode;
48
+ this.deprecations = options.deprecations?.length ? options.deprecations : undefined;
41
49
  this.stdoutWrite =
42
50
  streams.stdout ??
43
51
  (line => {
@@ -61,7 +69,14 @@ export class Output {
61
69
  // `index.ts`, and `--debug` tracing in `client-factory.ts` — never to a
62
70
  // success payload.
63
71
  if (this.mode === 'json' || !textRenderer) {
64
- this.stdoutWrite(JSON.stringify(data, null, 2));
72
+ const withDeprecations = this.mode === 'json' &&
73
+ this.deprecations &&
74
+ typeof data === 'object' &&
75
+ data !== null &&
76
+ !Array.isArray(data)
77
+ ? { ...data, deprecations: this.deprecations }
78
+ : data;
79
+ this.stdoutWrite(JSON.stringify(withDeprecations, null, 2));
65
80
  return;
66
81
  }
67
82
  this.stdoutWrite(textRenderer(data));
@@ -197,6 +197,8 @@ export const TRIGGER_RUN_RESPONSE_SCHEMA = v.looseObject({
197
197
  // `dashboard` line only when the key is present.
198
198
  dashboardUrl: v.optional(v.string()),
199
199
  executionUrl: v.optional(v.string()),
200
+ // Present-or-omitted echo of the request's `skipDependencies: true`; no default.
201
+ skipDependencies: v.optional(v.boolean()),
200
202
  });
201
203
  // ---------------------------------------------------------------------------
202
204
  // POST /tests/{testId}/runs/rerun
@@ -322,6 +324,7 @@ export const BATCH_RUN_FRESH_RESPONSE_SCHEMA = v.looseObject({
322
324
  // echo was served by a backend that cut the batch / ran a plain override.
323
325
  admission: v.optional(v.picklist(['budget', 'all'])),
324
326
  previewName: v.optional(v.string()),
327
+ skipDependencies: v.optional(v.boolean()),
325
328
  });
326
329
  /**
327
330
  * `POST /api/cli/v1/testlist/{listId}/run`. Mirrors the batch-run-fresh shape so