test(fetch): add full test coverage for fetchHeaders#83
Open
dmchaledev wants to merge 1 commit into
Open
Conversation
The network layer (fetch.ts) had 0% test coverage despite being the core execution path for all CLI and URL-based usage. This adds 12 tests covering header normalisation, request options, body cleanup, error propagation, and timeout/AbortController behaviour (both default 10 s and custom values). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kn8Rc4Kadu6EF4FChwp9kj
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.
Problem
src/fetch.ts— the module responsible for every live URL scan — had 0% test coverage. This means the primary user-facing path (CLI andanalyze(url)) was entirely untested despite the rest of the library having ~92% coverage.Solution
Adds
test/fetch.test.tswith 12 focused unit tests covering:GET,redirect: 'follow',AbortSignal)body.cancel()called){}timeoutMsrespectedAll tests use
vi.stubGlobal('fetch', vi.fn())so no real network calls are made. Timeout behaviour is verified withvi.useFakeTimers()and realAbortSignalobjects (no mocking ofAbortController).Test results
No new dependencies. No production code changes.
Generated by Claude Code