skills/bun-test-reporters/SKILL.md
Test Reporters
npx skillsauth add jarle/bun-skills Bun Test ReportersInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
bun test supports different output formats through reporters. This document covers both built-in reporters and how to implement your own custom reporters.
By default, bun test outputs results to the console in a human-readable format:
test/package-json-lint.test.ts:
✓ test/package.json [0.88ms]
✓ test/js/third_party/grpc-js/package.json [0.18ms]
✓ test/js/third_party/svelte/package.json [0.21ms]
✓ test/js/third_party/express/package.json [1.05ms]
4 pass
0 fail
4 expect() calls
Ran 4 tests in 1.44ms
When a terminal doesn't support colors, the output avoids non-ascii characters:
test/package-json-lint.test.ts:
(pass) test/package.json [0.48ms]
(pass) test/js/third_party/grpc-js/package.json [0.10ms]
(pass) test/js/third_party/svelte/package.json [0.04ms]
(pass) test/js/third_party/express/package.json [0.04ms]
4 pass
0 fail
4 expect() calls
Ran 4 tests across 1 files. [0.66ms]
The dots reporter shows . for passing tests and F for failures—useful for large test suites.
bun test --dots
bun test --reporter=dots
For CI/CD environments, Bun supports generating JUnit XML reports. JUnit XML is a widely-adopted format for test results that can be parsed by many CI/CD systems, including GitLab, Jenkins, and others.
To generate a JUnit XML report, use the --reporter=junit flag along with --reporter-outfile to specify the output file:
bun test --reporter=junit --reporter-outfile=./junit.xml
This continues to output to the console as usual while also writing the JUnit XML report to the specified path at the end of the test run.
You can also configure the JUnit reporter in your bunfig.toml file:
[test.reporter]
junit = "path/to/junit.xml" # Output path for JUnit XML report
The JUnit reporter automatically includes environment information as <properties> in the XML output. This can be helpful for tracking test runs in CI environments.
Specifically, 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 |
This makes it easier to track which environment and commit a particular test run was for.
The JUnit reporter currently has a few limitations that will be addressed in future updates:
stdout and stderr output from individual tests are not included in the reportBun test automatically detects when it's running inside GitHub Actions and emits GitHub Actions annotations to the console directly. No special configuration is needed beyond installing Bun and running bun test.
For a GitHub Actions workflow configuration example, see the CI/CD integration section of the CLI documentation.
Bun allows developers to implement custom test reporters by extending the WebKit Inspector Protocol with additional testing-specific domains.
To support test reporting, Bun extends the standard WebKit Inspector Protocol with two custom domains:
These extensions allow you to build custom reporting tools that can receive detailed information about test execution in real-time.
Custom reporters can listen for these key 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 occursdevelopment
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling