test: add CLI and fetch integration tests (closes #65)#89
Open
dmchaledev wants to merge 1 commit into
Open
Conversation
- Add test/cli.test.ts covering the CI-gate exit-code path (D/F → exit 1, A+ → exit 0), --json output, --version/-v, --help/-h, missing-URL error, network-error propagation, and --timeout forwarding to fetchHeaders. - Add test/fetch.test.ts covering header lowercasing, GET-method enforcement, AbortSignal wiring, body cancellation, null-body safety, and timeout abort. - Change cli.ts to use top-level `await main()` so dynamic import() resolves only after main() finishes, enabling the vi.resetModules() test pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FvB5dYob9rjdUekNBA4Dvn
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
Closes #65.
cli.tsandfetch.tshad 0% test coverage despite the CLI's exit-code CI gate being the library's primary use case. This PR adds two test files that cover those modules end-to-end with no new runtime or dev dependencies.test/cli.test.ts— 12 cases:--jsonemits valid JSON withgrade,score,headers, andurlfields--version/-vprints a semver string--help/-hprints usage text--timeout 3000forwards{ timeoutMs: 3000 }tofetchHeaderstest/fetch.test.ts— 7 cases:GETis used instead ofHEAD(prevents false-negative CSP omissions)AbortSignalis wired into thefetchcallnullbody doesn't throwtimeoutMselapsessrc/cli.ts— one-line change:main()→await main(). The module's top-level call was unwaited, so a dynamicimport('../src/cli.js')would resolve beforemain()ran, making it impossible to capture output or exit codes in tests. Top-levelawaitin an ESM module (already used by this package:"type": "module","module": "NodeNext") makes the import wait formain()to settle.Generated by Claude Code