Skip to content

Commit 7940ccf

Browse files
committed
docs & test
1 parent 093feed commit 7940ccf

File tree

2 files changed

+79
-3
lines changed

2 files changed

+79
-3
lines changed

docs/runtime/bunfig.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,41 @@ This is useful for:
249249

250250
The `--concurrent` CLI flag will override this setting when specified.
251251

252+
### `test.onlyFailures`
253+
254+
When enabled, only failed tests are displayed in the output. This helps reduce noise in large test suites by hiding passing tests. Default `false`.
255+
256+
```toml
257+
[test]
258+
onlyFailures = true
259+
```
260+
261+
This is equivalent to using the `--only-failures` flag when running `bun test`.
262+
263+
### `test.reporter`
264+
265+
Configure the test reporter settings.
266+
267+
#### `test.reporter.dots`
268+
269+
Enable the dots reporter, which displays a compact output showing a dot for each test. Default `false`.
270+
271+
```toml
272+
[test.reporter]
273+
dots = true
274+
```
275+
276+
#### `test.reporter.junit`
277+
278+
Enable JUnit XML reporting and specify the output file path.
279+
280+
```toml
281+
[test.reporter]
282+
junit = "test-results.xml"
283+
```
284+
285+
This generates a JUnit XML report that can be consumed by CI systems and other tools.
286+
252287
## Package manager
253288

254289
Package management is a complex issue; to support a range of use cases, the behavior of `bun install` can be configured under the `[install]` section.

test/js/bun/test/only-failures.test.ts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, test } from "bun:test";
2-
import { bunEnv, bunExe, normalizeBunSnapshot } from "harness";
2+
import { bunEnv, bunExe, normalizeBunSnapshot, tempDir } from "harness";
33

4-
test("only-failures flag should show only failures", async () => {
4+
test.concurrent("only-failures flag should show only failures", async () => {
55
const result = await Bun.spawn({
66
cmd: [bunExe(), "test", import.meta.dir + "/only-failures.fixture.ts", "--only-failures"],
77
stdout: "pipe",
@@ -56,7 +56,7 @@ test("only-failures flag should show only failures", async () => {
5656
`);
5757
});
5858

59-
test("only-failures flag should work with multiple files", async () => {
59+
test.concurrent("only-failures flag should work with multiple files", async () => {
6060
const result = await Bun.spawn({
6161
cmd: [
6262
bunExe(),
@@ -77,3 +77,44 @@ test("only-failures flag should work with multiple files", async () => {
7777
expect(normalizeBunSnapshot(stderr)).toContain("(fail) another failing test");
7878
expect(normalizeBunSnapshot(stderr)).not.toContain("(pass)");
7979
});
80+
81+
test.concurrent("only-failures should work via bunfig.toml", async () => {
82+
using dir = tempDir("bunfig-only-failures", {
83+
"bunfig.toml": `
84+
[test]
85+
onlyFailures = true
86+
`,
87+
"my.test.ts": `
88+
import { test, expect } from "bun:test";
89+
90+
test("passing test", () => {
91+
expect(1 + 1).toBe(2);
92+
});
93+
94+
test("failing test", () => {
95+
expect(1 + 1).toBe(3);
96+
});
97+
98+
test("another passing test", () => {
99+
expect(true).toBe(true);
100+
});
101+
`,
102+
});
103+
104+
const result = await Bun.spawn({
105+
cmd: [bunExe(), "test"],
106+
stdout: "pipe",
107+
stderr: "pipe",
108+
env: bunEnv,
109+
cwd: String(dir),
110+
});
111+
112+
const exitCode = await result.exited;
113+
const stderr = await result.stderr.text();
114+
115+
expect(exitCode).toBe(1);
116+
// Should only show the failing test
117+
expect(normalizeBunSnapshot(stderr, dir)).toContain("(fail) failing test");
118+
// Should not show passing tests
119+
expect(normalizeBunSnapshot(stderr, dir)).not.toContain("(pass)");
120+
});

0 commit comments

Comments
 (0)