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