bun-types 1.2.23-canary.20250923T140639 → 1.2.23-canary.20250924T140620

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bun.d.ts CHANGED
@@ -636,7 +636,7 @@ declare module "bun" {
636
636
  * import { YAML } from "bun";
637
637
  *
638
638
  * console.log(YAML.parse("123")) // 123
639
- * console.log(YAML.parse("123")) // null
639
+ * console.log(YAML.parse("null")) // null
640
640
  * console.log(YAML.parse("false")) // false
641
641
  * console.log(YAML.parse("abc")) // "abc"
642
642
  * console.log(YAML.parse("- abc")) // [ "abc" ]
@@ -653,7 +653,10 @@ declare module "bun" {
653
653
  *
654
654
  * @param input The JavaScript value to stringify.
655
655
  * @param replacer Currently not supported.
656
- * @param space A number for how many spaces each level of indentation gets, or a string used as indentation. The number is clamped between 0 and 10, and the first 10 characters of the string are used.
656
+ * @param space A number for how many spaces each level of indentation gets, or a string used as indentation.
657
+ * Without this parameter, outputs flow-style (single-line) YAML.
658
+ * With this parameter, outputs block-style (multi-line) YAML.
659
+ * The number is clamped between 0 and 10, and the first 10 characters of the string are used.
657
660
  * @returns A string containing the YAML document.
658
661
  *
659
662
  * @example
@@ -661,19 +664,24 @@ declare module "bun" {
661
664
  * import { YAML } from "bun";
662
665
  *
663
666
  * const input = {
664
- * abc: "def"
667
+ * abc: "def",
668
+ * num: 123
665
669
  * };
670
+ *
671
+ * // Without space - flow style (single-line)
666
672
  * console.log(YAML.stringify(input));
667
- * // # output
673
+ * // {abc: def,num: 123}
674
+ *
675
+ * // With space - block style (multi-line)
676
+ * console.log(YAML.stringify(input, null, 2));
668
677
  * // abc: def
678
+ * // num: 123
669
679
  *
670
680
  * const cycle = {};
671
681
  * cycle.obj = cycle;
672
- * console.log(YAML.stringify(cycle));
673
- * // # output
674
- * // &root
675
- * // obj:
676
- * // *root
682
+ * console.log(YAML.stringify(cycle, null, 2));
683
+ * // &1
684
+ * // obj: *1
677
685
  */
678
686
  export function stringify(input: unknown, replacer?: undefined | null, space?: string | number): string;
679
687
  }
package/docs/api/fetch.md CHANGED
@@ -336,7 +336,7 @@ This will print the request and response headers to your terminal:
336
336
  ```sh
337
337
  [fetch] > HTTP/1.1 GET http://example.com/
338
338
  [fetch] > Connection: keep-alive
339
- [fetch] > User-Agent: Bun/1.2.23-canary.20250923T140639
339
+ [fetch] > User-Agent: Bun/1.2.23-canary.20250924T140620
340
340
  [fetch] > Accept: */*
341
341
  [fetch] > Host: example.com
342
342
  [fetch] > Accept-Encoding: gzip, deflate, br
package/docs/api/spawn.md CHANGED
@@ -140,7 +140,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
140
140
  ```ts
141
141
  const proc = Bun.spawn(["bun", "--version"]);
142
142
  const text = await proc.stdout.text();
143
- console.log(text); // => "1.2.23-canary.20250923T140639\n"
143
+ console.log(text); // => "1.2.23-canary.20250924T140620\n"
144
144
  ```
145
145
 
146
146
  Configure the output stream by passing one of the following values to `stdout/stderr`:
package/docs/api/yaml.md CHANGED
@@ -3,6 +3,7 @@ In Bun, YAML is a first-class citizen alongside JSON and TOML.
3
3
  Bun provides built-in support for YAML files through both runtime APIs and bundler integration. You can
4
4
 
5
5
  - Parse YAML strings with `Bun.YAML.parse`
6
+ - Stringify JavaScript objects to YAML with `Bun.YAML.stringify`
6
7
  - import & require YAML files as modules at runtime (including hot reloading & watch mode support)
7
8
  - import & require YAML files in frontend apps via bun's bundler
8
9
 
@@ -104,7 +105,7 @@ const data = Bun.YAML.parse(yaml);
104
105
 
105
106
  #### Error Handling
106
107
 
107
- `Bun.YAML.parse()` throws a `SyntaxError` if the YAML is invalid:
108
+ `Bun.YAML.parse()` throws an error if the YAML is invalid:
108
109
 
109
110
  ```ts
110
111
  try {
@@ -114,6 +115,175 @@ try {
114
115
  }
115
116
  ```
116
117
 
118
+ ### `Bun.YAML.stringify()`
119
+
120
+ Convert a JavaScript value into a YAML string. The API signature matches `JSON.stringify`:
121
+
122
+ ```ts
123
+ YAML.stringify(value, replacer?, space?)
124
+ ```
125
+
126
+ - `value`: The value to convert to YAML
127
+ - `replacer`: Currently only `null` or `undefined` (function replacers not yet supported)
128
+ - `space`: Number of spaces for indentation (e.g., `2`) or a string to use for indentation. **Without this parameter, outputs flow-style (single-line) YAML**
129
+
130
+ #### Basic Usage
131
+
132
+ ```ts
133
+ import { YAML } from "bun";
134
+
135
+ const data = {
136
+ name: "John Doe",
137
+ age: 30,
138
+ hobbies: ["reading", "coding"],
139
+ };
140
+
141
+ // Without space - outputs flow-style (single-line) YAML
142
+ console.log(YAML.stringify(data));
143
+ // {name: John Doe,age: 30,hobbies: [reading,coding]}
144
+
145
+ // With space=2 - outputs block-style (multi-line) YAML
146
+ console.log(YAML.stringify(data, null, 2));
147
+ // name: John Doe
148
+ // age: 30
149
+ // hobbies:
150
+ // - reading
151
+ // - coding
152
+ ```
153
+
154
+ #### Output Styles
155
+
156
+ ```ts
157
+ const arr = [1, 2, 3];
158
+
159
+ // Flow style (single-line) - default
160
+ console.log(YAML.stringify(arr));
161
+ // [1,2,3]
162
+
163
+ // Block style (multi-line) - with indentation
164
+ console.log(YAML.stringify(arr, null, 2));
165
+ // - 1
166
+ // - 2
167
+ // - 3
168
+ ```
169
+
170
+ #### String Quoting
171
+
172
+ `YAML.stringify()` automatically quotes strings when necessary:
173
+
174
+ - Strings that would be parsed as YAML keywords (`true`, `false`, `null`, `yes`, `no`, etc.)
175
+ - Strings that would be parsed as numbers
176
+ - Strings containing special characters or escape sequences
177
+
178
+ ```ts
179
+ const examples = {
180
+ keyword: "true", // Will be quoted: "true"
181
+ number: "123", // Will be quoted: "123"
182
+ text: "hello world", // Won't be quoted: hello world
183
+ empty: "", // Will be quoted: ""
184
+ };
185
+
186
+ console.log(YAML.stringify(examples, null, 2));
187
+ // keyword: "true"
188
+ // number: "123"
189
+ // text: hello world
190
+ // empty: ""
191
+ ```
192
+
193
+ #### Cycles and References
194
+
195
+ `YAML.stringify()` automatically detects and handles circular references using YAML anchors and aliases:
196
+
197
+ ```ts
198
+ const obj = { name: "root" };
199
+ obj.self = obj; // Circular reference
200
+
201
+ const yamlString = YAML.stringify(obj, null, 2);
202
+ console.log(yamlString);
203
+ // &root
204
+ // name: root
205
+ // self:
206
+ // *root
207
+
208
+ // Objects with shared references
209
+ const shared = { id: 1 };
210
+ const data = {
211
+ first: shared,
212
+ second: shared,
213
+ };
214
+
215
+ console.log(YAML.stringify(data, null, 2));
216
+ // first:
217
+ // &first
218
+ // id: 1
219
+ // second:
220
+ // *first
221
+ ```
222
+
223
+ #### Special Values
224
+
225
+ ```ts
226
+ // Special numeric values
227
+ console.log(YAML.stringify(Infinity)); // .inf
228
+ console.log(YAML.stringify(-Infinity)); // -.inf
229
+ console.log(YAML.stringify(NaN)); // .nan
230
+ console.log(YAML.stringify(0)); // 0
231
+ console.log(YAML.stringify(-0)); // -0
232
+
233
+ // null and undefined
234
+ console.log(YAML.stringify(null)); // null
235
+ console.log(YAML.stringify(undefined)); // undefined (returns undefined, not a string)
236
+
237
+ // Booleans
238
+ console.log(YAML.stringify(true)); // true
239
+ console.log(YAML.stringify(false)); // false
240
+ ```
241
+
242
+ #### Complex Objects
243
+
244
+ ```ts
245
+ const config = {
246
+ server: {
247
+ port: 3000,
248
+ host: "localhost",
249
+ ssl: {
250
+ enabled: true,
251
+ cert: "/path/to/cert.pem",
252
+ key: "/path/to/key.pem",
253
+ },
254
+ },
255
+ database: {
256
+ connections: [
257
+ { name: "primary", host: "db1.example.com" },
258
+ { name: "replica", host: "db2.example.com" },
259
+ ],
260
+ },
261
+ features: {
262
+ auth: true,
263
+ "rate-limit": 100, // Keys with special characters are preserved
264
+ },
265
+ };
266
+
267
+ const yamlString = YAML.stringify(config, null, 2);
268
+ console.log(yamlString);
269
+ // server:
270
+ // port: 3000
271
+ // host: localhost
272
+ // ssl:
273
+ // enabled: true
274
+ // cert: /path/to/cert.pem
275
+ // key: /path/to/key.pem
276
+ // database:
277
+ // connections:
278
+ // - name: primary
279
+ // host: db1.example.com
280
+ // - name: replica
281
+ // host: db2.example.com
282
+ // features:
283
+ // auth: true
284
+ // rate-limit: 100
285
+ ```
286
+
117
287
  ## Module Import
118
288
 
119
289
  ### ES Modules
package/docs/cli/pm.md CHANGED
@@ -213,7 +213,7 @@ To display current package version and help:
213
213
 
214
214
  ```bash
215
215
  $ bun pm version
216
- bun pm version v1.2.23-canary.20250923T140639 (ca7428e9)
216
+ bun pm version v1.2.23-canary.20250924T140620 (ca7428e9)
217
217
  Current package version: v1.0.0
218
218
 
219
219
  Increment:
@@ -7,7 +7,7 @@ Use `bun publish` to publish a package to the npm registry.
7
7
  $ bun publish
8
8
 
9
9
  ## Output
10
- bun publish v1.2.23-canary.20250923T140639 (ca7428e9)
10
+ bun publish v1.2.23-canary.20250924T140620 (ca7428e9)
11
11
 
12
12
  packed 203B package.json
13
13
  packed 224B README.md
@@ -9,7 +9,7 @@ $ bunx nuxi init my-nuxt-app
9
9
  ✔ Which package manager would you like to use?
10
10
  bun
11
11
  ◐ Installing dependencies...
12
- bun install v1.2.23-canary.20250923T140639 (16b4bf34)
12
+ bun install v1.2.23-canary.20250924T140620 (16b4bf34)
13
13
  + @nuxt/devtools@0.8.2
14
14
  + nuxt@3.7.0
15
15
  785 packages installed [2.67s]
@@ -15,7 +15,7 @@ This will add the package to `peerDependencies` in `package.json`.
15
15
  ```json-diff
16
16
  {
17
17
  "peerDependencies": {
18
- + "@types/bun": "^1.2.23-canary.20250923T140639"
18
+ + "@types/bun": "^1.2.23-canary.20250924T140620"
19
19
  }
20
20
  }
21
21
  ```
@@ -27,7 +27,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
27
27
  ```json-diff
28
28
  {
29
29
  "peerDependencies": {
30
- "@types/bun": "^1.2.23-canary.20250923T140639"
30
+ "@types/bun": "^1.2.23-canary.20250924T140620"
31
31
  },
32
32
  "peerDependenciesMeta": {
33
33
  + "@types/bun": {
@@ -97,7 +97,7 @@ $ bun update
97
97
  $ bun update @types/bun --latest
98
98
 
99
99
  # Update a dependency to a specific version
100
- $ bun update @types/bun@1.2.23-canary.20250923T140639
100
+ $ bun update @types/bun@1.2.23-canary.20250924T140620
101
101
 
102
102
  # Update all dependencies to the latest versions
103
103
  $ bun update --latest
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
21
21
 
22
22
  ```sh
23
23
  $ bun test
24
- bun test v1.2.23-canary.20250923T140639 (9c68abdb)
24
+ bun test v1.2.23-canary.20250924T140620 (9c68abdb)
25
25
 
26
26
  test.test.js:
27
27
  ✓ add [0.87ms]
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
47
47
 
48
48
  ```sh
49
49
  $ bun test test3
50
- bun test v1.2.23-canary.20250923T140639 (9c68abdb)
50
+ bun test v1.2.23-canary.20250924T140620 (9c68abdb)
51
51
 
52
52
  test3.test.js:
53
53
  ✓ add [1.40ms]
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
85
85
 
86
86
  ```sh
87
87
  $ bun test -t add
88
- bun test v1.2.23-canary.20250923T140639 (9c68abdb)
88
+ bun test v1.2.23-canary.20250924T140620 (9c68abdb)
89
89
 
90
90
  test.test.js:
91
91
  ✓ add [1.79ms]
@@ -18,7 +18,7 @@ The first time this test is executed, Bun will evaluate the value passed into `e
18
18
 
19
19
  ```sh
20
20
  $ bun test test/snap
21
- bun test v1.2.23-canary.20250923T140639 (9c68abdb)
21
+ bun test v1.2.23-canary.20250924T140620 (9c68abdb)
22
22
 
23
23
  test/snap.test.ts:
24
24
  ✓ snapshot [1.48ms]
@@ -61,7 +61,7 @@ Later, when this test file is executed again, Bun will read the snapshot file an
61
61
 
62
62
  ```sh
63
63
  $ bun test
64
- bun test v1.2.23-canary.20250923T140639 (9c68abdb)
64
+ bun test v1.2.23-canary.20250924T140620 (9c68abdb)
65
65
 
66
66
  test/snap.test.ts:
67
67
  ✓ snapshot [1.05ms]
@@ -78,7 +78,7 @@ To update snapshots, use the `--update-snapshots` flag.
78
78
 
79
79
  ```sh
80
80
  $ bun test --update-snapshots
81
- bun test v1.2.23-canary.20250923T140639 (9c68abdb)
81
+ bun test v1.2.23-canary.20250924T140620 (9c68abdb)
82
82
 
83
83
  test/snap.test.ts:
84
84
  ✓ snapshot [0.86ms]
@@ -29,7 +29,7 @@ To regenerate snapshots, use the `--update-snapshots` flag.
29
29
 
30
30
  ```sh
31
31
  $ bun test --update-snapshots
32
- bun test v1.2.23-canary.20250923T140639 (9c68abdb)
32
+ bun test v1.2.23-canary.20250924T140620 (9c68abdb)
33
33
 
34
34
  test/snap.test.ts:
35
35
  ✓ snapshot [0.86ms]
@@ -5,7 +5,7 @@ name: Get the current Bun version
5
5
  Get the current version of Bun in a semver format.
6
6
 
7
7
  ```ts#index.ts
8
- Bun.version; // => "1.2.23-canary.20250923T140639"
8
+ Bun.version; // => "1.2.23-canary.20250924T140620"
9
9
  ```
10
10
 
11
11
  ---
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
14
14
  ```bash#macOS/Linux_(curl)
15
15
  $ curl -fsSL https://bun.com/install | bash # for macOS, Linux, and WSL
16
16
  # to install a specific version
17
- $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.23-canary.20250923T140639"
17
+ $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.23-canary.20250924T140620"
18
18
  ```
19
19
 
20
20
  ```bash#npm
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
189
189
 
190
190
  ### Installing a specific version of Bun on Linux/Mac
191
191
 
192
- To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.23-canary.20250923T140639`.
192
+ To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.23-canary.20250924T140620`.
193
193
 
194
194
  ```sh
195
- $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.23-canary.20250923T140639"
195
+ $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.23-canary.20250924T140620"
196
196
  ```
197
197
 
198
198
  ### Installing a specific version of Bun on Windows
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
201
201
 
202
202
  ```sh
203
203
  # PowerShell:
204
- $ iex "& {$(irm https://bun.com/install.ps1)} -Version 1.2.23-canary.20250923T140639"
204
+ $ iex "& {$(irm https://bun.com/install.ps1)} -Version 1.2.23-canary.20250924T140620"
205
205
  ```
206
206
 
207
207
  ## Downloading Bun binaries directly
@@ -232,6 +232,23 @@ Set path where coverage reports will be saved. Please notice, that it works only
232
232
  coverageDir = "path/to/somewhere" # default "coverage"
233
233
  ```
234
234
 
235
+ ### `test.concurrentTestGlob`
236
+
237
+ Specify a glob pattern to automatically run matching test files with concurrent test execution enabled. Test files matching this pattern will behave as if the `--concurrent` flag was passed, running all tests within those files concurrently.
238
+
239
+ ```toml
240
+ [test]
241
+ concurrentTestGlob = "**/concurrent-*.test.ts"
242
+ ```
243
+
244
+ This is useful for:
245
+
246
+ - Gradually migrating test suites to concurrent execution
247
+ - Running integration tests concurrently while keeping unit tests sequential
248
+ - Separating fast concurrent tests from tests that require sequential execution
249
+
250
+ The `--concurrent` CLI flag will override this setting when specified.
251
+
235
252
  ## Package manager
236
253
 
237
254
  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.
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
124
124
  This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
125
125
 
126
126
  ```sh
127
- [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.23-canary.20250923T140639" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
127
+ [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.23-canary.20250924T140620" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
128
128
  [fetch] > HTTP/1.1 POST https://example.com/
129
129
  [fetch] > content-type: application/json
130
130
  [fetch] > Connection: keep-alive
131
- [fetch] > User-Agent: Bun/1.2.23-canary.20250923T140639
131
+ [fetch] > User-Agent: Bun/1.2.23-canary.20250924T140620
132
132
  [fetch] > Accept: */*
133
133
  [fetch] > Host: example.com
134
134
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -170,7 +170,7 @@ This prints the following to the console:
170
170
  [fetch] > HTTP/1.1 POST https://example.com/
171
171
  [fetch] > content-type: application/json
172
172
  [fetch] > Connection: keep-alive
173
- [fetch] > User-Agent: Bun/1.2.23-canary.20250923T140639
173
+ [fetch] > User-Agent: Bun/1.2.23-canary.20250924T140620
174
174
  [fetch] > Accept: */*
175
175
  [fetch] > Host: example.com
176
176
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -46,6 +46,25 @@ smol = true # Reduce memory usage during test runs
46
46
 
47
47
  This is equivalent to using the `--smol` flag on the command line.
48
48
 
49
+ ### Test execution
50
+
51
+ #### concurrentTestGlob
52
+
53
+ Automatically run test files matching a glob pattern with concurrent test execution enabled. This is useful for gradually migrating test suites to concurrent execution or for running specific test types concurrently.
54
+
55
+ ```toml
56
+ [test]
57
+ concurrentTestGlob = "**/concurrent-*.test.ts" # Run files matching this pattern concurrently
58
+ ```
59
+
60
+ Test files matching this pattern will behave as if the `--concurrent` flag was passed, running all tests within those files concurrently. This allows you to:
61
+
62
+ - Gradually migrate your test suite to concurrent execution
63
+ - Run integration tests concurrently while keeping unit tests sequential
64
+ - Separate fast concurrent tests from tests that require sequential execution
65
+
66
+ The `--concurrent` CLI flag will override this setting when specified, forcing all tests to run concurrently regardless of the glob pattern.
67
+
49
68
  ### Coverage options
50
69
 
51
70
  In addition to the options documented in the [coverage documentation](./coverage.md), the following options are available:
package/docs/test/dom.md CHANGED
@@ -55,7 +55,7 @@ Let's run this test with `bun test`:
55
55
 
56
56
  ```bash
57
57
  $ bun test
58
- bun test v1.2.23-canary.20250923T140639
58
+ bun test v1.2.23-canary.20250924T140620
59
59
 
60
60
  dom.test.ts:
61
61
  ✓ dom test [0.82ms]
@@ -0,0 +1,132 @@
1
+ # Concurrent Test Glob Example
2
+
3
+ This example demonstrates how to use the `concurrentTestGlob` option to selectively run tests concurrently based on file naming patterns.
4
+
5
+ ## Project Structure
6
+
7
+ ```text
8
+ my-project/
9
+ ├── bunfig.toml
10
+ ├── tests/
11
+ │ ├── unit/
12
+ │ │ ├── math.test.ts # Sequential
13
+ │ │ └── utils.test.ts # Sequential
14
+ │ └── integration/
15
+ │ ├── concurrent-api.test.ts # Concurrent
16
+ │ └── concurrent-database.test.ts # Concurrent
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ ### bunfig.toml
22
+
23
+ ```toml
24
+ [test]
25
+ # Run all test files with "concurrent-" prefix concurrently
26
+ concurrentTestGlob = "**/concurrent-*.test.ts"
27
+ ```
28
+
29
+ ## Test Files
30
+
31
+ ### Unit Test (Sequential)
32
+
33
+ `tests/unit/math.test.ts`
34
+
35
+ ```typescript
36
+ import { test, expect } from "bun:test";
37
+
38
+ // These tests run sequentially by default
39
+ // Good for tests that share state or have specific ordering requirements
40
+ let sharedState = 0;
41
+
42
+ test("addition", () => {
43
+ sharedState = 5 + 3;
44
+ expect(sharedState).toBe(8);
45
+ });
46
+
47
+ test("uses previous state", () => {
48
+ // This test depends on the previous test's state
49
+ expect(sharedState).toBe(8);
50
+ });
51
+ ```
52
+
53
+ ### Integration Test (Concurrent)
54
+
55
+ `tests/integration/concurrent-api.test.ts`
56
+
57
+ ```typescript
58
+ import { test, expect } from "bun:test";
59
+
60
+ // These tests automatically run concurrently due to filename matching the glob pattern.
61
+ // Using test() is equivalent to test.concurrent() when the file matches concurrentTestGlob.
62
+ // Each test is independent and can run in parallel.
63
+
64
+ test("fetch user data", async () => {
65
+ const response = await fetch("/api/user/1");
66
+ expect(response.ok).toBe(true);
67
+ });
68
+
69
+ test("fetch posts", async () => {
70
+ const response = await fetch("/api/posts");
71
+ expect(response.ok).toBe(true);
72
+ });
73
+
74
+ test("fetch comments", async () => {
75
+ const response = await fetch("/api/comments");
76
+ expect(response.ok).toBe(true);
77
+ });
78
+ ```
79
+
80
+ ## Running Tests
81
+
82
+ ```bash
83
+ # Run all tests - concurrent-*.test.ts files will run concurrently
84
+ bun test
85
+
86
+ # Override: Force ALL tests to run concurrently
87
+ # Note: This overrides bunfig.toml and runs all tests concurrently, regardless of glob
88
+ bun test --concurrent
89
+
90
+ # Run only unit tests (sequential)
91
+ bun test tests/unit
92
+
93
+ # Run only integration tests (concurrent due to glob pattern)
94
+ bun test tests/integration
95
+ ```
96
+
97
+ ## Benefits
98
+
99
+ 1. **Gradual Migration**: Migrate to concurrent tests file by file by renaming them
100
+ 2. **Clear Organization**: File naming convention indicates execution mode
101
+ 3. **Performance**: Integration tests run faster in parallel
102
+ 4. **Safety**: Unit tests remain sequential where needed
103
+ 5. **Flexibility**: Easy to change execution mode by renaming files
104
+
105
+ ## Migration Strategy
106
+
107
+ To migrate existing tests to concurrent execution:
108
+
109
+ 1. Start with independent integration tests
110
+ 2. Rename files to match the glob pattern: `mv api.test.ts concurrent-api.test.ts`
111
+ 3. Verify tests still pass
112
+ 4. Monitor for race conditions or shared state issues
113
+ 5. Continue migrating stable tests incrementally
114
+
115
+ ## Tips
116
+
117
+ - Use descriptive prefixes: `concurrent-`, `parallel-`, `async-`
118
+ - Keep related sequential tests together
119
+ - Document why certain tests must remain sequential
120
+ - Use `test.concurrent()` for fine-grained control in sequential files
121
+ (In files matched by `concurrentTestGlob`, plain `test()` already runs concurrently)
122
+ - Consider separate globs for different test types:
123
+
124
+ ```toml
125
+ [test]
126
+ # Multiple patterns for different test categories
127
+ concurrentTestGlob = [
128
+ "**/integration/*.test.ts",
129
+ "**/e2e/*.test.ts",
130
+ "**/concurrent-*.test.ts"
131
+ ]
132
+ ```
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.23-canary.20250923T140639",
2
+ "version": "1.2.23-canary.20250924T140620",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "types": "./index.d.ts",
package/test.d.ts CHANGED
@@ -230,6 +230,11 @@ declare module "bun:test" {
230
230
  * Marks this group of tests to be executed concurrently.
231
231
  */
232
232
  concurrent: Describe<T>;
233
+ /**
234
+ * Marks this group of tests to be executed serially (one after another),
235
+ * even when the --concurrent flag is used.
236
+ */
237
+ serial: Describe<T>;
233
238
  /**
234
239
  * Runs this group of tests, only if `condition` is true.
235
240
  *
@@ -459,6 +464,11 @@ declare module "bun:test" {
459
464
  * Runs the test concurrently with other concurrent tests.
460
465
  */
461
466
  concurrent: Test<T>;
467
+ /**
468
+ * Forces the test to run serially (not in parallel),
469
+ * even when the --concurrent flag is used.
470
+ */
471
+ serial: Test<T>;
462
472
  /**
463
473
  * Runs this test, if `condition` is true.
464
474
  *
@@ -491,6 +501,13 @@ declare module "bun:test" {
491
501
  * @param condition if the test should run concurrently
492
502
  */
493
503
  concurrentIf(condition: boolean): Test<T>;
504
+ /**
505
+ * Forces the test to run serially (not in parallel), if `condition` is true.
506
+ * This applies even when the --concurrent flag is used.
507
+ *
508
+ * @param condition if the test should run serially
509
+ */
510
+ serialIf(condition: boolean): Test<T>;
494
511
  /**
495
512
  * Returns a function that runs for each item in `table`.
496
513
  *