Skip to content

test: add comprehensive test coverage + fetch timeout + CLI help/version#2

Open
dmchaledev wants to merge 1 commit into
mainfrom
owl-alpha/add-tests-and-timeout-20260524035837
Open

test: add comprehensive test coverage + fetch timeout + CLI help/version#2
dmchaledev wants to merge 1 commit into
mainfrom
owl-alpha/add-tests-and-timeout-20260524035837

Conversation

@dmchaledev
Copy link
Copy Markdown
Contributor

Summary

Improves test coverage, adds fetch timeout support, and enhances the CLI with --help, --version, and --timeout flags.

Changes

New tests (44 added, 15 → 59 total):

  • Full coverage for checkPermissionsPolicy
  • Full coverage for checkCrossOriginPolicies
  • Edge cases for checkXFrameOptions (invalid values, CSP frame-ancestors fallback)
  • Edge cases for checkReferrerPolicy (all strong/weak values)
  • Grade boundary tests for all grades A+ through F
  • Tests for analyze() convenience function (async path)

Coverage improvements:

  • Branch coverage: 73.7% → 96.1%
  • rules.ts: 93.3% → 100% statement coverage
  • analyzer.ts: 100% across all metrics

New features:

  • fetchHeaders(url, { timeoutMs? }) — configurable timeout with AbortController (default 10s)
  • CLI --help / -h flag with usage documentation
  • CLI --version / -v flag
  • CLI --timeout <ms> flag
  • Exported FetchOptions type from index.ts

Testing

  • npm run typecheck — passes
  • npm test — 59/59 tests pass
  • npm run build — passes

- Add 44 new tests covering all rule functions (checkPermissionsPolicy,
  checkCrossOriginPolicies, checkXFrameOptions edge cases, grade boundaries)
- Branch coverage improved from 73.7% → 96.1%
- rules.ts and analyzer.ts now at 100% statement coverage
- Add configurable timeout to fetchHeaders (default 10s) with AbortController
- Add --help and --version flags to CLI
- Add --timeout option to CLI for configurable fetch timeout
- Export FetchOptions type from index.ts
- Export FetchOptions type for library consumers
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