Files
bun.sh/test/cli
Claude Bot d329278996 feat(test): add --coverage-changes flag for PR coverage reporting
Adds a new `--coverage-changes` CLI flag for `bun test` that reports code coverage
specifically for lines that changed compared to a base branch (default: main).

Features:
- Merged coverage table with "% Chang" column showing coverage for changed lines only
- AI agent detection (AGENT=1 or CLAUDECODE env) outputs XML prompts for uncovered code:
  - `<file>` tags for uncovered line ranges
  - `<function>` tags for entirely uncovered new functions with correct line numbers
- Exits with code 1 if changed lines coverage is below threshold (default 90%)
- Skips test files from changed lines tracking when coverageSkipTestFiles is enabled
- Uses bun.Ordinal for unambiguous line number handling (0-indexed internal, 1-indexed display)

Usage:
  bun test --coverage --coverage-changes        # Compare against main
  bun test --coverage --coverage-changes=develop  # Compare against develop

Example output with AI agent prompts (AGENT=1):
```
File       | % Funcs | % Lines | % Chang | Uncovered Line #s
lib.ts     |   50.00 |   66.67 |    0.00 |

Coverage for changed lines (0.00%) is below threshold (90.00%)

<errors>
  <file path="lib.ts">
    In lib.ts, lines 5 do not have test coverage. Write tests to cover these lines.
  </file>
  <function path="lib.ts" startLine="5" endLine="6">
    In lib.ts, the function at lines 5-6 is never called. Write a test that calls this function, or delete it if it is dead code.
  </function>
</errors>
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-17 07:33:47 +00:00
..
2025-10-11 08:23:25 -07:00