Skip to content

test: raise coverage from 73% to 100% statements - #3

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1787168040-test-coverage
Open

devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1787168040-test-coverage

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Baseline vitest run --coverage was 73.69% statements / 75.63% branches, with the gaps concentrated in modules that had no test file at all. This adds unit tests for those, taking coverage to 100% statements / lines, 95.95% branches without touching src/.

Where the coverage was missing and what now covers it:

module before new tests
formatter.ts 0% test/formatter.test.ts — every statusIcon branch, each report section, the 20-entry cap on the valid-links list, redirect-chain printing (only when >1 hop), broken links with/without occurrences, summary footer
index.ts 0% test/index.test.ts — asserts the exact export surface, so a dropped re-export fails a test
checker.ts performRequest 70% (lines 123-160 unhit) test/checker.request.test.ts — HEAD→GET fallback on 405/501 and on throw, multi-hop chains, relative Location resolution, 3xx without Location, Too many redirects (> 10)
report.ts 83% test/report.write.test.ts — writeJsonReport/writeMarkdownReport against a temp dir, remaining statusEmoji cases, duplicate/insecure/chain issue lines
scanner.ts 64% branch test/scanner.events.test.ts — onFileFound/onLinkChecked ordering and index/total, single-file and trailing-slash paths, non-markdown direct path, timeout/malformed/redirect/http counters, empty scan

performRequest is unreachable through the requestFn seam that existing tests use, so its test file mocks axios.create and injects fake head/get:

vi.mock('axios', () => ({ default: { create: createMock } }));
headMock.mockResolvedValueOnce(response(302, '/moved')).mockResolvedValueOnce(response(200));
await performRequest('https://example.com/docs/page', 5000); // finalUrl === 'https://example.com/moved'

One config change: src/action-entry.ts is added to the coverage exclude list. It is a 3-line shim (void runAction()) around the already-excluded src/github.ts, so it was reporting 0% and depressing the total for no signal.

Remaining uncovered branches are defensive ?? '' fallbacks in markdown.ts (unreachable given the regexes) and the two real-network defaults in scanner.ts.

Link to Devin session: https://app.devin.ai/sessions/57116b8344064675a8572be9cf98e16b
Requested by: @lahcenassmira

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@lahcenassmira lahcenassmira self-assigned this Aug 19, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant