1
1
import { expect , test } from "bun:test" ;
2
- import { bunEnv , bunExe , normalizeBunSnapshot } from "harness" ;
2
+ import { bunEnv , bunExe , normalizeBunSnapshot , tempDir } from "harness" ;
3
3
4
- test ( "only-failures flag should show only failures" , async ( ) => {
4
+ test . concurrent ( "only-failures flag should show only failures" , async ( ) => {
5
5
const result = await Bun . spawn ( {
6
6
cmd : [ bunExe ( ) , "test" , import . meta. dir + "/only-failures.fixture.ts" , "--only-failures" ] ,
7
7
stdout : "pipe" ,
@@ -56,7 +56,7 @@ test("only-failures flag should show only failures", async () => {
56
56
` ) ;
57
57
} ) ;
58
58
59
- test ( "only-failures flag should work with multiple files" , async ( ) => {
59
+ test . concurrent ( "only-failures flag should work with multiple files" , async ( ) => {
60
60
const result = await Bun . spawn ( {
61
61
cmd : [
62
62
bunExe ( ) ,
@@ -77,3 +77,44 @@ test("only-failures flag should work with multiple files", async () => {
77
77
expect ( normalizeBunSnapshot ( stderr ) ) . toContain ( "(fail) another failing test" ) ;
78
78
expect ( normalizeBunSnapshot ( stderr ) ) . not . toContain ( "(pass)" ) ;
79
79
} ) ;
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