@testsprite/testsprite-cli 0.10.0 → 0.12.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 (61) hide show
  1. package/README.md +65 -41
  2. package/dist/commands/auth.d.ts +5 -1
  3. package/dist/commands/auth.js +17 -5
  4. package/dist/commands/ci.js +34 -4
  5. package/dist/commands/init.d.ts +6 -1
  6. package/dist/commands/init.js +13 -5
  7. package/dist/commands/project-env.d.ts +90 -0
  8. package/dist/commands/project-env.js +486 -0
  9. package/dist/commands/project.d.ts +19 -0
  10. package/dist/commands/project.js +92 -25
  11. package/dist/commands/test.d.ts +42 -4
  12. package/dist/commands/test.js +344 -49
  13. package/dist/commands/testlist.js +29 -3
  14. package/dist/commands/tunnel.d.ts +2 -2
  15. package/dist/commands/tunnel.js +139 -31
  16. package/dist/index.js +42 -14
  17. package/dist/lib/client-factory.d.ts +4 -1
  18. package/dist/lib/client-factory.js +14 -4
  19. package/dist/lib/client-tag.d.ts +13 -0
  20. package/dist/lib/client-tag.js +44 -0
  21. package/dist/lib/conflict-reason.d.ts +43 -2
  22. package/dist/lib/conflict-reason.js +100 -14
  23. package/dist/lib/credentials.d.ts +4 -0
  24. package/dist/lib/credentials.js +43 -4
  25. package/dist/lib/cron.js +8 -1
  26. package/dist/lib/errors.d.ts +44 -1
  27. package/dist/lib/errors.js +69 -12
  28. package/dist/lib/gh-output.d.ts +25 -11
  29. package/dist/lib/gh-output.js +36 -13
  30. package/dist/lib/http.d.ts +21 -2
  31. package/dist/lib/http.js +45 -8
  32. package/dist/lib/local-target.d.ts +32 -0
  33. package/dist/lib/local-target.js +77 -0
  34. package/dist/lib/output.d.ts +27 -1
  35. package/dist/lib/output.js +22 -3
  36. package/dist/lib/response-schemas.d.ts +5 -2
  37. package/dist/lib/response-schemas.js +39 -1
  38. package/dist/lib/runs.types.d.ts +50 -2
  39. package/dist/lib/target-url.d.ts +1 -1
  40. package/dist/lib/target-url.js +35 -12
  41. package/dist/lib/telemetry.d.ts +174 -4
  42. package/dist/lib/telemetry.js +286 -13
  43. package/dist/lib/tunnel-session.d.ts +13 -2
  44. package/dist/lib/tunnel-session.js +92 -23
  45. package/dist/lib/tunnel.types.d.ts +3 -1
  46. package/dist/lib/version-notice.d.ts +20 -1
  47. package/dist/lib/version-notice.js +59 -12
  48. package/dist/vendor/tunnel-client/client.d.ts +11 -0
  49. package/dist/vendor/tunnel-client/client.js +383 -56
  50. package/dist/vendor/tunnel-client/config.d.ts +11 -3
  51. package/dist/vendor/tunnel-client/config.js +11 -3
  52. package/dist/vendor/tunnel-client/types.d.ts +26 -1
  53. package/dist/vendor/tunnel-client/types.js +1 -0
  54. package/dist/vendor/tunnel-client/ws-compat.d.ts +3 -2
  55. package/dist/vendor/tunnel-client/ws-compat.js +3 -2
  56. package/dist/version.d.ts +1 -1
  57. package/dist/version.js +1 -1
  58. package/package.json +2 -1
  59. package/skills/testsprite-onboard.skill.md +74 -59
  60. package/skills/testsprite-verify.codex.md +82 -97
  61. package/skills/testsprite-verify.skill.md +64 -15
@@ -28,7 +28,10 @@ machine's own loopback address (`localhost` / `127.0.0.1` / `::1` — not a LAN
28
28
  or RFC1918 address, and not a general local-network escape hatch) to the test
29
29
  runner. Two constraints: frontend tests only (a backend test's target is baked
30
30
  into its generated code, so run it normally), and it needs an API key with the
31
- `run:tunnel` scope — a 403 there means mint a new key.
31
+ `run:tunnel` scope. Keys minted before that scope existed must be replaced;
32
+ the CLI names the missing scope (exit 3). Add `--env <name>` to log in
33
+ with a named project environment's test account instead of the default one's
34
+ (`testsprite project env list <projectId>` shows the names).
32
35
 
33
36
  If the user explicitly named a tool (the CLI or the MCP), honor that choice
34
37
  regardless of which one the change's reachability would otherwise suggest.
@@ -40,8 +43,9 @@ The skip list is narrow:
40
43
  - Docs-only edits (`docs/**`, `*.md`, comments).
41
44
  - Pure build/config edits (`tsconfig*`, lint/prettier config, lockfile bumps with
42
45
  no behavior change).
43
- - This repo isn't actually wired to TestSprite (no project linked, no creds).
44
- Don't pull the user into a setup flow they didn't ask for — say so and stop.
46
+ - Credentials are unavailable. Explain the missing setup; do not claim a
47
+ verified result. If credentials exist but a local project is missing, use
48
+ the bootstrap below.
45
49
 
46
50
  Otherwise, run it.
47
51
 
@@ -62,8 +66,8 @@ What does **not** count: unit tests / typecheck / lint; drafting a plan without
62
66
 
63
67
  If the project has **no tests at all**, that's the `testsprite-onboard` skill's
64
68
  job, not this one — seed a suite first (it can generate the proposals for you
65
- with `testsprite test plan generate` / `test plan accept`, or author them by
66
- hand). Seeding is a deliberate setup pass, not part of the verify loop.
69
+ with `testsprite test plan generate` / `test plan accept` for a deployed target;
70
+ local projects require authored plans and `test create --plan-from`). Seeding is a deliberate setup pass, not part of the verify loop.
67
71
 
68
72
  If you can't satisfy this — no creds, no valid target URL, repo not linked —
69
73
  **say so explicitly**: "Feature shipped but I could not run any TestSprite test
@@ -92,6 +96,25 @@ In priority order:
92
96
  4. Still ambiguous → list the candidates and ask the user which to use (one short
93
97
  question; picking the wrong project wastes a run).
94
98
 
99
+ If no project exists for an app running only locally, bootstrap a frontend project
100
+ (V3 required), author a plan, and run the returned test id:
101
+
102
+ ```bash
103
+ testsprite project create --type frontend --name "<repo name>" --local <port> --local-host <host>
104
+ testsprite test create --plan-from plan.json --project <projectId>
105
+ testsprite test run <test-id> --local <port> --local-host <host> --output json
106
+ ```
107
+
108
+ Keep the app listening and use the same `--local-host` for creation and follow-up
109
+ runs. It selects both the probe and stored URL host: `localhost`, `127.0.0.1`
110
+ (default), or `::1`; omit it in both commands to use the default.
111
+ The port probe fails with exit 5 if nothing listens (`--skip-preflight`
112
+ bypasses it). Local projects skip exploration: `test plan generate` is refused
113
+ before charge (exit 6), so use `test create --plan-from` without `--run`, then
114
+ `test run --local`. V2-only local-project creation is unsupported (exit 7).
115
+ Portal runs are blocked for free until `project update <id> --url https://…`
116
+ sets a public URL. Keep the existing `--url` / `--target-url` flow for deployed apps.
117
+
95
118
  ## 3. Decide what to test
96
119
 
97
120
  Look at the diff (`git diff --stat`, then the changed files) to understand what
@@ -345,14 +368,17 @@ Batch is **FE-only.** For 3 backend tests, run `test create --type backend
345
368
 
346
369
  ## 4. Run
347
370
 
348
- All variants use `--wait` for a synchronous verdict, `--target-url <env-url>` for
349
- the deployment under test, and `--timeout 600` as a sane default.
371
+ For a deployed target, use `--target-url <env-url> --wait --timeout 600` after
372
+ that deployment contains the change. For a change running only on this machine,
373
+ use `testsprite test run <test-id> --local <port>` (frontend only); it implies
374
+ waiting and defaults to 1200 seconds. Create a missing test from a plan first,
375
+ without `--run`, then run its id with `--local`.
350
376
 
351
377
  ```bash
352
378
  # (a) existing test
353
379
  testsprite test run <test-id> --target-url <env-url> --wait --timeout 600 --output json
354
380
 
355
- # (a-rerun) cheap replay of an existing test. FE: replays the saved script (auto-heal on — more
381
+ # (a-rerun) replay of a deployed test (V3 FE: 0.5 credit). Replays saved code (auto-heal on — more
356
382
  # lenient than a fresh run; for strict verification of a new change prefer `test run`).
357
383
  # BE: dispatches the WHOLE dependency closure — producers and teardowns run too, not just <test-id>,
358
384
  # so expect their side effects (fixtures re-created, teardown deletes) and extra runs in history.
@@ -395,11 +421,31 @@ Key behaviors:
395
421
  only, see "When to run" above) — don't skip the run over this.
396
422
  - `--wait` long-polls until terminal and handles its own backoff — don't wrap it
397
423
  in a retry loop.
398
- - Exit codes: `0` = passed; `1` = failed / blocked / cancelled; `7` = timeout.
399
- Treat `7` as inconclusive (resume with `testsprite test wait <run-id>`), not a
400
- regression — except a `--local` run: its exit 7 already cancelled the run
401
- (the tunnel closes with the process, so there is nothing to resume), so
402
- don't suggest `test wait` there; re-run with `--local` again instead.
424
+ - `--local` implies `--wait`, with a default timeout of 1200 seconds (ordinary
425
+ waits default to 600). Run one frontend test per invocation; parallel
426
+ invocations are fine, but `--all --local` is refused (exit 5). There are
427
+ 5 live tunnel bindings per user; `tunnel_binding_limit` is exit 11 and is not
428
+ auto-retried. Reuse a live tunnel with `--tunnel-client` or stop an unused one.
429
+ - Keep the early `Run <runId>` line on **stderr**, emitted as soon as the trigger
430
+ returns; `Dashboard: <url>` follows when supplied. Preserve the id even if
431
+ the wait later stops; stdout remains the normal JSON result channel.
432
+ - An **owned** local run is cancelled by default when waiting stops (timeout,
433
+ Ctrl-C, or a polling failure), then its tunnel closes. Read the reported
434
+ cancellation outcome. A run cancelled before it finished is refunded.
435
+ `--no-cancel-on-interrupt` detaches instead, but the owned tunnel still closes.
436
+ A borrower using `--tunnel-client` never automatically cancels its run or
437
+ closes the adopted tunnel; its owner must remain running.
438
+ A second `tunnel start` or process using the same credential takes over, and the first exits **10**.
439
+ - Exit codes: `0` = passed; `1` = failed / blocked / cancelled; `7` = timeout
440
+ or unsupported. An owned local timeout is inconclusive: start a **new**
441
+ `testsprite test run <test-id> --local <port> --timeout 1800`, keeping the same
442
+ `--local-host <host>` if used; do not suggest `test wait` for that closed tunnel. Resume **ordinary or adopted-tunnel**
443
+ waits with `testsprite test wait <run-id>` only while the target is reachable
444
+ (and the adopted tunnel's owner remains alive).
445
+ - A case last run through a tunnel stays local: a later Portal Run, schedule,
446
+ or bare CLI run is a free BLOCKED (`tunnel-required`, exit 6). Use `--local`
447
+ again or explicitly retarget with a public `--target-url`. V3 local runs use
448
+ the agent path, never saved-code replay, and preserve the test's saved code.
403
449
  - Batch: `create-batch --run --wait` creates the tests (FE-only) and fans
404
450
  out triggers in one call (bounded by `--max-concurrency`), emitting
405
451
  `{ results: [...] }` that mirrors the single-test `test run --wait`
@@ -449,8 +495,11 @@ The product/environment is the problem (believe these) when:
449
495
  read-only", "page 404s");
450
496
  - the trace blames infra (deploy lag, auth gate, missing fixture).
451
497
 
452
- Scope step counts to the **current run** — `test steps` is cumulative across runs;
453
- filter on the run-id before counting.
498
+ `test steps <test-id>` shows the **latest run's steps**. For the run you are
499
+ verifying, use `testsprite test steps <test-id> --run-id <run-id> --output json`
500
+ with the id from the early stderr receipt. An empty latest run is not evidence
501
+ from an earlier run; use `test result <test-id> --history` to choose one explicitly.
502
+ Older backends may return cumulative bare steps; pin `--run-id` before counting.
454
503
 
455
504
  **Read the testing agent's failure summary skeptically — it can conflate two
456
505
  failure phases.** When a flow produces an artifact that then runs against an external