You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tests for setup's config writer: invalid, unchanged, read-failure and write-failure paths #407
configureJsonClient edits users' MCP client config files, but only the happy path is tested. The invalid-JSON, unchanged, read-failure and write-failure branches have no tests.
Where
src/setup.ts:327-376
src/__tests__/setup.test.ts:118-125
src/__tests__/setup.test.ts:176-222
Details
configureJsonClient writes the user's MCP client config (Cursor, VS Code, Claude Desktop). mergeServerConfig is unit-tested for the invalid status (setup.test.ts:122-124, JSONC with comments, arrays). However, runSetup is only driven through the create, merge, conflict, dry-run and decline paths. In the per-line run, setup.ts lines 336-337 (read failure), 343-347 (unchanged and invalid messages and returns) and 373-374 (write failure) have 0 hits. The invalid return is the guard that stops setup from replacing a commented mcp.json.
Impact
A regression in the switch, such as a fall-through or a reordered case, would overwrite a user's JSONC config. A backup is taken first, so the damage is recoverable but confusing. Read and write failures are also unverified to exit non-zero.
Steps to reproduce
Delete return false; after the invalid message (setup.ts:347). setup.test.ts still passes.
Suggested fix
Add runSetup cases using the existing fakeDeps. (1) An existing VS Code mcp.json containing // comment, run with --yes: the file is unchanged, no .bak- file is created, the output mentions "left ... alone", and the exit code reflects the failure. (2) An already-identical entry: "already configured" and no write. (3) readFile throws: "could not read", no write. (4) writeFile throws: "could not write", and the result is false.
Activity