Skip to content

fix(tests): coverage below threshold + fetchWithRetry wastes 3s per test #7

@shouze

Description

@shouze

Problem

  1. bun test --coverage fails: lines at 69.64% (threshold 75%)

    • src/api/github-api.ts (not unit-testable) pollutes the global coverage
    • Many branches in pure-function modules untested
  2. Tests in api-utils.test.ts using Retry-After: "0" fall through to exponential back-off (1 s delay) because getRetryDelayMs checked seconds > 0, treating "0" as "no Retry-After header". Two tests take 3.1 s each → full suite takes 6.5 s.

Fix

  • bunfig.toml: extend coveragePathIgnorePatterns to exclude non-unit-testable files (github-api.ts, commands/, tui/editor.ts, upgrade.ts, github-issue-ops.ts)
  • api-utils.ts: change seconds > 0seconds >= 0 so Retry-After: "0" returns 0 ms delay
  • Add targeted tests for all uncovered branches in checklist.ts, stdin.ts, api-utils.ts, ownership.ts

Result

  • 75 tests, 0 failures, 96.54% lines (up from 69.64%), 95.77% functions
  • Test suite runtime: 31 ms (down from 6.5 s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions