Skip to main content
Bun’s test runner supports built-in code coverage reporting via the --coverage flag.
terminal

To set a minimum coverage threshold, add the following line to your bunfig.toml. This requires that 90% of your codebase is covered by tests.
bunfig.toml

If your test suite does not meet this threshold, bun test will exit with a non-zero exit code to signal a failure.
terminal

Different thresholds can be set for line-level and function-level coverage.
bunfig.toml

See Docs > Test runner > Coverage for complete documentation on code coverage reporting in Bun.