test: add CLI test coverage (39 tests)#28
Merged
robotlearning123 merged 4 commits intomainfrom Mar 2, 2026
Merged
Conversation
Add isMain check so importing cli.ts for testing doesn't trigger automatic argument parsing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mock globalThis.fetch to verify HTTP method, URL, request body, query params, output formatting, --json flag, --url flag, and error handling for every CLI command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
Code reviewFound 1 issue:
Lines 30 to 35 in 7e9222c 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
255 tests across 6 suites. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
Code reviewNo issues found. Previous issue (CLAUDE.md test count/file listing) has been fixed in ab8e9e5. Re-checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
process.argv[1] won't match import.meta.url when CLI is invoked through an npm symlink (npm link / npm install -g). Normalize both paths with realpathSync to fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cli.tsto exportprogramand guardparseAsync()withisMaincheck (+3 lines) for testabilitysrc/__tests__/cli.test.tswith 39 BDD-style tests covering all 11 CLI commandsCoverage
--json(parameterized across 6 commands),--urlApproach
Mock
globalThis.fetchto verify HTTP method + URL + body for each command. Captureconsole.logto verify output formatting (table vs JSON). No subprocess spawning needed.Test plan
npx tsc --noEmit— zero errorsnode --import tsx --test src/__tests__/cli.test.ts— 39/39 passsrc/__tests__/*.test.ts— 255/255 pass🤖 Generated with Claude Code