inspector/clients/cli/__tests__
Repository files (latest commit first)
Filename Latest commit message Latest commit date
cliffhall 70cd4f05ac test: discriminate --protocol-era wiring against a modern-only server (#2208)
The legacy and auto e2e cases both connect to the legacy stdio fixture
whether or not the flag reaches negotiation, since auto falls back. Run
initialize against an HTTP test server that rejects the legacy handshake:
the default must fail, and --protocol-era modern must connect and report
the 2026-07-28 protocol version. Deleting the serverOptions assignment in
cli.ts now fails this case (Copilot review, PR #2372).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZ4rrvH6xaCfrst75gJh7x
Signed-off-by: cliffhall <cliff@futurescale.com>
2026-09-14 00:59:23 -04:00
..
helpers fix(cli): apply a server's persisted mcp.json metadata 2026-08-24 19:32:23 -04:00
app-info.test.ts cli: Wave 3 — programmatic review path (rollup of #1573–#1575) (#1655) 2026-07-11 22:14:23 -04:00
clear-stored-auth-for-relogin.test.ts test(auth): stub the clock in both floor regression tests 2026-09-05 02:00:08 -04:00
cli-oauth-navigation.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
cli.test.ts test(proxy): isolate proxy env per file; word the guard failure by candidate source 2026-08-23 23:00:28 -04:00
cliOAuth.test.ts test(cli,tui): typecheck the __tests__ dirs (#1791) (#1799) 2026-07-27 12:05:35 -04:00
e2e.test.ts fix: address Copilot review round 1 on #2323 2026-09-12 10:46:28 -04:00
emit-result.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
error-handler.test.ts feat: bound connect attempts with a 30 s default connectionTimeout (#2320) 2026-09-13 20:54:23 -04:00
format-json.test.ts cli: Wave 3 — programmatic review path (rollup of #1573–#1575) (#1655) 2026-07-11 22:14:23 -04:00
format-output.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
headers.test.ts feat: port CLI, TUI, and launcher from v1.5 into v2 (#1452) 2026-06-14 20:27:49 -04:00
metadata.test.ts fix(cli): apply a server's persisted mcp.json metadata 2026-08-24 19:32:23 -04:00
method-types.test.ts feat: allow complex JSON values in request _meta 2026-08-23 12:23:40 -04:00
methods.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
oauth-interactive.test.ts fix: address Copilot review round 2, and drop the asyncUtilTimeout raise 2026-09-12 11:49:30 -04:00
oauth-runner.test.ts Guided-auth removal, OAuth smoke testing, and TUI/CLI support (#1531) 2026-06-29 15:35:51 -04:00
open-url.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
programmatic-ergonomics.test.ts test: discriminate --protocol-era wiring against a modern-only server (#2208) 2026-09-14 00:59:23 -04:00
README.md CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
relogin-revocation.test.ts fix(auth): refuse a grant whose authorization server cannot be established (#2144) 2026-08-28 06:18:58 -04:00
run-method-mocks.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
run-method-skills.test.ts fix: address Copilot review round 17 on #2248 2026-09-07 23:12:28 -04:00
run-method.test.ts fix: invoke the registered SIGINT listener directly in run-method.test instead of emitting a process-wide signal 2026-08-12 08:57:35 -07:00
schema-lint-report.test.ts fix: scan only subschema positions, await stderr, show the whole report 2026-08-25 03:10:37 -04:00
servers-list.test.ts fix: redact secrets nested inside metadata in servers/show 2026-08-23 14:03:40 -04:00
skills-verify-cli.test.ts fix: address Copilot review round 15 on #2248 2026-09-07 22:47:32 -04:00
stored-auth.test.ts fix(auth): cover the CLI refresh path and tighten the well-known match 2026-08-28 01:11:51 -04:00
style.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
tools.test.ts cli: Wave 3 — programmatic review path (rollup of #1573–#1575) (#1655) 2026-07-11 22:14:23 -04:00

CLI Tests

Tests live under __tests__/ and run via Vitest.

  • Most tests import runCli() in-process (see helpers/cli-runner.ts) so clients/cli/src is measured under the coverage gate. Suite-wide helpers/mock-open-url.ts (vitest setupFiles) mocks open-url so an armed interactive OAuth path cannot launch a real browser.
  • e2e.test.ts (and root scripts/smoke-cli.mjs) spawn the built binary for shebang / process.exit paths — pretest builds test-servers + the CLI bundle first.

Scripts (from clients/cli/)

npm test                  # pretest build + all tests
npm run test:cli          # subset: cli.test.ts
npm run test:cli-tools    # subset: tools.test.ts
npm run test:cli-headers  # subset: headers.test.ts
npm run test:cli-metadata # subset: metadata.test.ts
npm run test:coverage     # build + ≥90 per-file coverage gate
npm run validate          # format:check && lint && typecheck && test

Test files

File Focus
cli.test.ts Core connect / method / config matrix
tools.test.ts tools/call argument coercion
headers.test.ts --header merging
metadata.test.ts --metadata / --tool-metadata
methods.test.ts Method allow-list / rejection
app-info.test.ts --app-info probe paths
format-json.test.ts --format json envelopes
format-output.test.ts Text/json writers
emit-result.test.ts Result emission helpers
method-types.test.ts ONE_SHOT_METHODS / guards
run-method.test.ts Handler dispatch against a real test server
run-method-mocks.test.ts Handler edge cases with mocks
servers-list.test.ts servers/list / servers/show + redaction
cliOAuth.test.ts Connect / mid-RPC OAuth recovery
cli-oauth-navigation.test.ts OSC 8, arm/disarm, MCP_AUTO_OPEN_ENABLED
open-url.test.ts open package wrapper
oauth-runner.test.ts Runner client-config / CIMD flags
oauth-interactive.test.ts Loopback callback OAuth (in-process)
stored-auth.test.ts --use-stored-auth / handoff / wait
clear-stored-auth-for-relogin.test.ts Dual-key --relogin clear
programmatic-ergonomics.test.ts Flag conflicts, timeouts, ergonomics
error-handler.test.ts Exit codes / error shaping
style.test.ts ANSI / OSC 8 helpers
e2e.test.ts Out-of-process binary smoke
helpers/assertions.test.ts Assertion helpers

Helpers

Helper Role
helpers/cli-runner.ts In-process runCli with stdout/stderr capture
helpers/mock-open-url.ts Suite-wide open-url mock (vitest setupFiles)
helpers/assertions.ts expectCliSuccess / expectCliFailure / output matchers
helpers/fixtures.ts Temp config / client.json factories

OAuth interactive tests stub or drive the loopback callback in-process rather than requiring a real browser.