bun test supports different output formats through reporters, both built-in and custom.
Built-in Reporters
Default Console Reporter
By default,bun test outputs results to the console in a human-readable format:
terminal
terminal
Dots Reporter
The dots reporter shows. for passing tests and prints full error details for failures, useful for large test suites.
terminal
JUnit XML Reporter
For CI/CD environments, Bun can generate JUnit XML reports, a widely-adopted test result format that many CI/CD systems can parse, including GitLab and Jenkins.Using the JUnit Reporter
To generate a JUnit XML report, use the--reporter=junit flag along with --reporter-outfile to specify the output file:
terminal
Configuring via bunfig.toml
You can also configure the JUnit reporter inbunfig.toml:
bunfig.toml
Environment Variables in JUnit Reports
The JUnit reporter includes environment information as<properties> in the XML output, so you can tell which environment and commit a test run was for.
It includes the following environment variables when available:
| Environment Variable | Property Name | Description |
|---|---|---|
GITHUB_RUN_ID, GITHUB_SERVER_URL, GITHUB_REPOSITORY, CI_JOB_URL | ci | CI build information |
GITHUB_SHA, CI_COMMIT_SHA, GIT_SHA | commit | Git commit identifiers |
| System hostname | hostname | Machine hostname |
Current Limitations
The JUnit reporter does not include:stdoutandstderroutput from individual tests- Precise timestamp fields per test case
GitHub Actions reporter
bun test detects when it’s running inside GitHub Actions and emits GitHub Actions annotations to the console directly. No configuration is needed beyond installing Bun and running bun test.
For an example GitHub Actions workflow, see CI/CD integration.
Custom Reporters
You can implement custom test reporters with Bun’s testing-specific extensions to the WebKit Inspector Protocol, which report detailed information about test execution in real time.Inspector Protocol for Testing
Bun extends the standard WebKit Inspector Protocol with two custom domains:- TestReporter: Reports test discovery, execution start, and completion events
- LifecycleReporter: Reports errors and exceptions during test execution
Key Events
Custom reporters can listen for these events:TestReporter.found: Emitted when a test is discoveredTestReporter.start: Emitted when a test starts runningTestReporter.end: Emitted when a test completesConsole.messageAdded: Emitted when console output occurs during a testLifecycleReporter.error: Emitted when an error or exception occurs