bun-types 1.3.3 → 1.3.4-canary.20251123T140630
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/CLAUDE.md +3 -3
- package/docs/bundler/css.mdx +1 -1
- package/docs/bundler/executables.mdx +33 -4
- package/docs/bundler/fullstack.mdx +3 -3
- package/docs/bundler/hot-reloading.mdx +2 -2
- package/docs/bundler/html-static.mdx +10 -9
- package/docs/bundler/index.mdx +27 -18
- package/docs/bundler/loaders.mdx +2 -2
- package/docs/bundler/macros.mdx +1 -1
- package/docs/feedback.mdx +2 -12
- package/docs/guides/binary/arraybuffer-to-array.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-blob.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-buffer.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-string.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-typedarray.mdx +1 -1
- package/docs/guides/binary/blob-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/blob-to-dataview.mdx +1 -1
- package/docs/guides/binary/blob-to-stream.mdx +1 -1
- package/docs/guides/binary/blob-to-string.mdx +1 -1
- package/docs/guides/binary/blob-to-typedarray.mdx +1 -1
- package/docs/guides/binary/buffer-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/buffer-to-blob.mdx +1 -1
- package/docs/guides/binary/buffer-to-readablestream.mdx +1 -1
- package/docs/guides/binary/buffer-to-string.mdx +1 -1
- package/docs/guides/binary/buffer-to-typedarray.mdx +1 -1
- package/docs/guides/binary/dataview-to-string.mdx +1 -1
- package/docs/guides/binary/typedarray-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/typedarray-to-blob.mdx +1 -1
- package/docs/guides/binary/typedarray-to-buffer.mdx +1 -1
- package/docs/guides/binary/typedarray-to-dataview.mdx +1 -1
- package/docs/guides/binary/typedarray-to-readablestream.mdx +1 -1
- package/docs/guides/binary/typedarray-to-string.mdx +1 -1
- package/docs/guides/deployment/aws-lambda.mdx +6 -6
- package/docs/guides/deployment/digital-ocean.mdx +7 -7
- package/docs/guides/deployment/vercel.mdx +1 -3
- package/docs/guides/ecosystem/discordjs.mdx +2 -2
- package/docs/guides/ecosystem/express.mdx +2 -2
- package/docs/guides/ecosystem/mongoose.mdx +1 -1
- package/docs/guides/ecosystem/neon-drizzle.mdx +2 -2
- package/docs/guides/ecosystem/neon-serverless-postgres.mdx +2 -2
- package/docs/guides/ecosystem/nuxt.mdx +1 -1
- package/docs/guides/ecosystem/prisma-postgres.mdx +1 -1
- package/docs/guides/ecosystem/prisma.mdx +1 -1
- package/docs/guides/ecosystem/qwik.mdx +4 -4
- package/docs/guides/ecosystem/sentry.mdx +2 -2
- package/docs/guides/ecosystem/sveltekit.mdx +1 -1
- package/docs/guides/ecosystem/tanstack-start.mdx +0 -1
- package/docs/guides/ecosystem/upstash.mdx +2 -2
- package/docs/guides/ecosystem/vite.mdx +2 -2
- package/docs/guides/html-rewriter/extract-links.mdx +2 -2
- package/docs/guides/html-rewriter/extract-social-meta.mdx +1 -1
- package/docs/guides/http/file-uploads.mdx +1 -1
- package/docs/guides/http/hot.mdx +1 -1
- package/docs/guides/http/server.mdx +1 -1
- package/docs/guides/http/simple.mdx +1 -1
- package/docs/guides/http/stream-file.mdx +3 -3
- package/docs/guides/http/tls.mdx +1 -1
- package/docs/guides/install/add-dev.mdx +1 -1
- package/docs/guides/install/add-git.mdx +1 -1
- package/docs/guides/install/add-optional.mdx +1 -1
- package/docs/guides/install/add-peer.mdx +3 -3
- package/docs/guides/install/add-tarball.mdx +1 -1
- package/docs/guides/install/add.mdx +1 -1
- package/docs/guides/install/azure-artifacts.mdx +3 -3
- package/docs/guides/install/custom-registry.mdx +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.mdx +1 -1
- package/docs/guides/install/git-diff-bun-lockfile.mdx +2 -1
- package/docs/guides/install/npm-alias.mdx +1 -1
- package/docs/guides/install/registry-scope.mdx +3 -3
- package/docs/guides/install/trusted.mdx +1 -1
- package/docs/guides/install/workspaces.mdx +1 -1
- package/docs/guides/install/yarnlock.mdx +4 -3
- package/docs/guides/process/ctrl-c.mdx +1 -1
- package/docs/guides/process/ipc.mdx +2 -2
- package/docs/guides/process/nanoseconds.mdx +1 -1
- package/docs/guides/process/os-signals.mdx +1 -1
- package/docs/guides/process/spawn-stderr.mdx +2 -2
- package/docs/guides/process/spawn-stdout.mdx +2 -2
- package/docs/guides/process/spawn.mdx +2 -2
- package/docs/guides/process/stdin.mdx +1 -1
- package/docs/guides/read-file/arraybuffer.mdx +2 -2
- package/docs/guides/read-file/buffer.mdx +1 -1
- package/docs/guides/read-file/exists.mdx +1 -1
- package/docs/guides/read-file/mime.mdx +1 -1
- package/docs/guides/read-file/stream.mdx +1 -1
- package/docs/guides/read-file/uint8array.mdx +1 -1
- package/docs/guides/read-file/watch.mdx +1 -1
- package/docs/guides/runtime/build-time-constants.mdx +3 -3
- package/docs/guides/runtime/cicd.mdx +1 -1
- package/docs/guides/runtime/codesign-macos-executable.mdx +1 -1
- package/docs/guides/runtime/delete-directory.mdx +1 -1
- package/docs/guides/runtime/delete-file.mdx +1 -1
- package/docs/guides/runtime/heap-snapshot.mdx +1 -1
- package/docs/guides/runtime/import-json.mdx +1 -1
- package/docs/guides/runtime/import-toml.mdx +1 -1
- package/docs/guides/runtime/import-yaml.mdx +1 -1
- package/docs/guides/runtime/read-env.mdx +1 -1
- package/docs/guides/runtime/set-env.mdx +2 -2
- package/docs/guides/runtime/shell.mdx +1 -1
- package/docs/guides/runtime/tsconfig-paths.mdx +1 -1
- package/docs/guides/runtime/typescript.mdx +1 -1
- package/docs/guides/runtime/vscode-debugger.mdx +1 -2
- package/docs/guides/runtime/web-debugger.mdx +1 -1
- package/docs/guides/streams/to-array.mdx +1 -1
- package/docs/guides/streams/to-arraybuffer.mdx +1 -1
- package/docs/guides/streams/to-blob.mdx +1 -1
- package/docs/guides/streams/to-buffer.mdx +1 -1
- package/docs/guides/streams/to-json.mdx +1 -1
- package/docs/guides/streams/to-string.mdx +1 -1
- package/docs/guides/streams/to-typedarray.mdx +1 -1
- package/docs/guides/test/bail.mdx +1 -1
- package/docs/guides/test/concurrent-test-glob.mdx +5 -2
- package/docs/guides/test/coverage-threshold.mdx +1 -1
- package/docs/guides/test/coverage.mdx +1 -1
- package/docs/guides/test/happy-dom.mdx +1 -1
- package/docs/guides/test/migrate-from-jest.mdx +7 -7
- package/docs/guides/test/mock-clock.mdx +2 -2
- package/docs/guides/test/mock-functions.mdx +1 -1
- package/docs/guides/test/rerun-each.mdx +1 -1
- package/docs/guides/test/run-tests.mdx +2 -2
- package/docs/guides/test/skip-tests.mdx +2 -2
- package/docs/guides/test/snapshot.mdx +4 -4
- package/docs/guides/test/spy-on.mdx +1 -1
- package/docs/guides/test/svelte-test.mdx +4 -4
- package/docs/guides/test/testing-library.mdx +3 -3
- package/docs/guides/test/timeout.mdx +1 -1
- package/docs/guides/test/todo-tests.mdx +2 -2
- package/docs/guides/test/update-snapshots.mdx +1 -1
- package/docs/guides/test/watch-mode.mdx +1 -1
- package/docs/guides/util/base64.mdx +1 -1
- package/docs/guides/util/deep-equals.mdx +3 -3
- package/docs/guides/util/deflate.mdx +1 -1
- package/docs/guides/util/entrypoint.mdx +2 -2
- package/docs/guides/util/escape-html.mdx +1 -1
- package/docs/guides/util/file-url-to-path.mdx +1 -1
- package/docs/guides/util/gzip.mdx +1 -1
- package/docs/guides/util/hash-a-password.mdx +1 -1
- package/docs/guides/util/import-meta-dir.mdx +2 -2
- package/docs/guides/util/import-meta-file.mdx +2 -2
- package/docs/guides/util/import-meta-path.mdx +2 -2
- package/docs/guides/util/javascript-uuid.mdx +2 -2
- package/docs/guides/util/main.mdx +1 -1
- package/docs/guides/util/path-to-file-url.mdx +1 -1
- package/docs/guides/util/sleep.mdx +1 -1
- package/docs/guides/util/version.mdx +2 -2
- package/docs/guides/util/which-path-to-executable-bin.mdx +1 -1
- package/docs/guides/websocket/context.mdx +1 -1
- package/docs/guides/websocket/simple.mdx +1 -1
- package/docs/guides/write-file/basic.mdx +2 -2
- package/docs/guides/write-file/blob.mdx +2 -2
- package/docs/guides/write-file/cat.mdx +2 -2
- package/docs/guides/write-file/file-cp.mdx +2 -2
- package/docs/guides/write-file/filesink.mdx +1 -1
- package/docs/guides/write-file/response.mdx +2 -2
- package/docs/guides/write-file/stdout.mdx +2 -2
- package/docs/guides/write-file/stream.mdx +2 -2
- package/docs/guides/write-file/unlink.mdx +1 -1
- package/docs/index.mdx +2 -2
- package/docs/installation.mdx +3 -3
- package/docs/pm/bunx.mdx +2 -2
- package/docs/pm/cli/install.mdx +8 -8
- package/docs/pm/cli/link.mdx +2 -2
- package/docs/pm/cli/outdated.mdx +3 -3
- package/docs/pm/cli/patch.mdx +2 -2
- package/docs/pm/cli/pm.mdx +1 -1
- package/docs/pm/cli/publish.mdx +1 -1
- package/docs/pm/filter.mdx +2 -2
- package/docs/pm/isolated-installs.mdx +3 -3
- package/docs/pm/npmrc.mdx +6 -6
- package/docs/pm/scopes-registries.mdx +1 -1
- package/docs/pm/security-scanner-api.mdx +2 -2
- package/docs/pm/workspaces.mdx +3 -4
- package/docs/project/benchmarking.mdx +1 -1
- package/docs/project/building-windows.mdx +1 -1
- package/docs/project/contributing.mdx +1 -1
- package/docs/project/license.mdx +1 -1
- package/docs/quickstart.mdx +3 -3
- package/docs/runtime/auto-install.mdx +1 -1
- package/docs/runtime/binary-data.mdx +1 -1
- package/docs/runtime/bun-apis.mdx +35 -35
- package/docs/runtime/bunfig.mdx +29 -3
- package/docs/runtime/c-compiler.mdx +3 -3
- package/docs/runtime/child-process.mdx +2 -2
- package/docs/runtime/cookies.mdx +19 -19
- package/docs/runtime/debugger.mdx +4 -4
- package/docs/runtime/environment-variables.mdx +24 -7
- package/docs/runtime/ffi.mdx +2 -2
- package/docs/runtime/file-io.mdx +2 -2
- package/docs/runtime/file-types.mdx +5 -5
- package/docs/runtime/globals.mdx +4 -4
- package/docs/runtime/http/error-handling.mdx +2 -2
- package/docs/runtime/http/routing.mdx +1 -1
- package/docs/runtime/http/server.mdx +5 -9
- package/docs/runtime/http/websockets.mdx +1 -1
- package/docs/runtime/index.mdx +2 -2
- package/docs/runtime/jsx.mdx +1 -1
- package/docs/runtime/module-resolution.mdx +2 -2
- package/docs/runtime/networking/fetch.mdx +4 -4
- package/docs/runtime/nodejs-compat.mdx +3 -3
- package/docs/runtime/plugins.mdx +1 -1
- package/docs/runtime/s3.mdx +4 -4
- package/docs/runtime/secrets.mdx +10 -7
- package/docs/runtime/sql.mdx +10 -10
- package/docs/runtime/sqlite.mdx +15 -4
- package/docs/runtime/templating/create.mdx +4 -4
- package/docs/runtime/transpiler.mdx +1 -1
- package/docs/runtime/utils.mdx +3 -3
- package/docs/runtime/watch-mode.mdx +1 -1
- package/docs/runtime/workers.mdx +5 -17
- package/docs/snippets/cli/publish.mdx +2 -2
- package/docs/test/configuration.mdx +1 -1
- package/docs/test/dom.mdx +1 -1
- package/docs/test/index.mdx +8 -8
- package/docs/test/reporters.mdx +1 -1
- package/docs/test/snapshots.mdx +3 -3
- package/docs/test/writing-tests.mdx +37 -0
- package/docs/typescript.mdx +2 -2
- package/package.json +3 -4
- package/docs/snippets/product-card.mdx +0 -32
- package/docs/snippets/product-tiles.mdx +0 -94
|
@@ -4,7 +4,7 @@ sidebarTitle: Spawn a child process and communicate using IPC
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Use [`Bun.spawn()`](
|
|
7
|
+
Use [`Bun.spawn()`](/docs/runtime/child-process) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes.
|
|
8
8
|
|
|
9
9
|
<Note>
|
|
10
10
|
This API is only compatible with other `bun` processes. Use `process.execPath` to get a path to the currently running
|
|
@@ -66,4 +66,4 @@ process.send({ message: "Hello from child as object" });
|
|
|
66
66
|
|
|
67
67
|
---
|
|
68
68
|
|
|
69
|
-
See [Docs > API > Child processes](
|
|
69
|
+
See [Docs > API > Child processes](/docs/runtime/child-process) for complete documentation.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Read stderr
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
When using [`Bun.spawn()`](
|
|
7
|
+
When using [`Bun.spawn()`](/docs/runtime/child-process), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
const proc = Bun.spawn(["echo", "hello"], {
|
|
@@ -31,4 +31,4 @@ if (errors) {
|
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
-
See [Docs > API > Child processes](
|
|
34
|
+
See [Docs > API > Child processes](/docs/runtime/child-process) for complete documentation.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Read stdout
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
When using [`Bun.spawn()`](
|
|
7
|
+
When using [`Bun.spawn()`](/docs/runtime/child-process), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
const proc = Bun.spawn(["echo", "hello"]);
|
|
@@ -25,4 +25,4 @@ const proc = Bun.spawn(["echo", "hello"], {
|
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
-
See [Docs > API > Child processes](
|
|
28
|
+
See [Docs > API > Child processes](/docs/runtime/child-process) for complete documentation.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Spawn child process
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Use [`Bun.spawn()`](
|
|
7
|
+
Use [`Bun.spawn()`](/docs/runtime/child-process) to spawn a child process.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
const proc = Bun.spawn(["echo", "hello"]);
|
|
@@ -40,4 +40,4 @@ output; // => "hello\n"
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
See [Docs > API > Child processes](
|
|
43
|
+
See [Docs > API > Child processes](/docs/runtime/child-process) for complete documentation.
|
|
@@ -15,7 +15,7 @@ const buffer = await file.arrayBuffer();
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
The binary content in the `ArrayBuffer` can then be read as a typed array, such as `Int8Array`. For `Uint8Array`, use [`.bytes()`](
|
|
18
|
+
The binary content in the `ArrayBuffer` can then be read as a typed array, such as `Int8Array`. For `Uint8Array`, use [`.bytes()`](/docs/guides/read-file/uint8array).
|
|
19
19
|
|
|
20
20
|
```ts index.ts icon="/icons/typescript.svg"
|
|
21
21
|
const buffer = await file.arrayBuffer();
|
|
@@ -27,4 +27,4 @@ bytes.length;
|
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
-
Refer to the [Typed arrays](
|
|
30
|
+
Refer to the [Typed arrays](/docs/runtime/binary-data#typedarray) docs for more information on working with typed arrays in Bun.
|
|
@@ -18,4 +18,4 @@ const buffer = Buffer.from(arrbuf);
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
Refer to [Binary data > Buffer](
|
|
21
|
+
Refer to [Binary data > Buffer](/docs/runtime/binary-data#buffer) for more information on working with `Buffer` and other binary data formats in Bun.
|
|
@@ -25,4 +25,4 @@ for await (const chunk of stream) {
|
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
-
Refer to the [Streams](
|
|
28
|
+
Refer to the [Streams](/docs/runtime/streams) documentation for more information on working with streams in Bun.
|
|
@@ -20,4 +20,4 @@ byteArray.length; // length of byteArray
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
Refer to [API > Binary data > Typed arrays](
|
|
23
|
+
Refer to [API > Binary data > Typed arrays](/docs/runtime/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun.
|
|
@@ -63,4 +63,4 @@ process.on("SIGINT", () => {
|
|
|
63
63
|
|
|
64
64
|
---
|
|
65
65
|
|
|
66
|
-
Refer to [API > Binary data > Typed arrays](
|
|
66
|
+
Refer to [API > Binary data > Typed arrays](/docs/runtime/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun.
|
|
@@ -290,6 +290,6 @@ bun build --compile --target=bun-windows-x64 --define PLATFORM='"windows"' src/a
|
|
|
290
290
|
|
|
291
291
|
## Related
|
|
292
292
|
|
|
293
|
-
- [Define constants at runtime](/guides/runtime/define-constant) - Using `--define` with `bun run`
|
|
294
|
-
- [Building executables](/bundler/executables) - Complete guide to `bun build --compile`
|
|
295
|
-
- [Bundler API](/bundler) - Full bundler documentation including `define` option
|
|
293
|
+
- [Define constants at runtime](/docs/guides/runtime/define-constant) - Using `--define` with `bun run`
|
|
294
|
+
- [Building executables](/docs/bundler/executables) - Complete guide to `bun build --compile`
|
|
295
|
+
- [Bundler API](/docs/bundler) - Full bundler documentation including `define` option
|
|
@@ -58,4 +58,4 @@ codesign -vvv --verify ./myapp
|
|
|
58
58
|
|
|
59
59
|
---
|
|
60
60
|
|
|
61
|
-
For more information on macOS codesigning, refer to [Apple's Code Signing documentation](https://developer.apple.com/documentation/security/code_signing_services). For details about creating single-file executables with Bun, see [Standalone Executables](/bundler/executables). This guide requires Bun v1.2.4 or newer.
|
|
61
|
+
For more information on macOS codesigning, refer to [Apple's Code Signing documentation](https://developer.apple.com/documentation/security/code_signing_services). For details about creating single-file executables with Bun, see [Standalone Executables](/docs/bundler/executables). This guide requires Bun v1.2.4 or newer.
|
|
@@ -25,4 +25,4 @@ To view V8 heap snapshots in Chrome DevTools:
|
|
|
25
25
|
3. Click the "Load" button (folder icon)
|
|
26
26
|
4. Select your `.heapsnapshot` file
|
|
27
27
|
|
|
28
|
-
<Frame></Frame>
|
|
28
|
+
<Frame></Frame>
|
|
@@ -43,4 +43,4 @@ data.author.name; // => "John Dough"
|
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
46
|
-
See [Docs > Runtime > TypeScript](
|
|
46
|
+
See [Docs > Runtime > TypeScript](/docs/runtime/typescript) for more information on using TypeScript with Bun.
|
|
@@ -29,4 +29,4 @@ data.author.name; // => "John Dough"
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
-
See [Docs > Runtime > TypeScript](
|
|
32
|
+
See [Docs > Runtime > TypeScript](/docs/runtime/typescript) for more information on using TypeScript with Bun.
|
|
@@ -34,4 +34,4 @@ FOOBAR=aaaaaa
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
-
See [Docs > Runtime > Environment variables](
|
|
37
|
+
See [Docs > Runtime > Environment variables](/docs/runtime/environment-variables) for more information on using environment variables with Bun.
|
|
@@ -21,7 +21,7 @@ Bun reads the following files automatically (listed in order of increasing prece
|
|
|
21
21
|
- `.env.production`, `.env.development`, `.env.test` (depending on value of `NODE_ENV`)
|
|
22
22
|
- `.env.local` (not loaded when `NODE_ENV=test`)
|
|
23
23
|
|
|
24
|
-
```
|
|
24
|
+
```ini .env icon="settings"
|
|
25
25
|
FOO=hello
|
|
26
26
|
BAR=world
|
|
27
27
|
```
|
|
@@ -48,4 +48,4 @@ $env:FOO="helloworld"; bun run dev
|
|
|
48
48
|
|
|
49
49
|
---
|
|
50
50
|
|
|
51
|
-
See [Docs > Runtime > Environment variables](
|
|
51
|
+
See [Docs > Runtime > Environment variables](/docs/runtime/environment-variables) for more information on using environment variables with Bun.
|
|
@@ -28,4 +28,4 @@ import { Button } from "@components/Button"; // imports from "./src/components/B
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
See [Docs > Runtime > TypeScript](
|
|
31
|
+
See [Docs > Runtime > TypeScript](/docs/runtime/typescript) for more information on using TypeScript with Bun.
|
|
@@ -48,4 +48,4 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
|
|
|
48
48
|
|
|
49
49
|
---
|
|
50
50
|
|
|
51
|
-
Refer to [Ecosystem > TypeScript](
|
|
51
|
+
Refer to [Ecosystem > TypeScript](/docs/runtime/typescript) for a complete guide to TypeScript support in Bun.
|
|
@@ -5,8 +5,7 @@ mode: center
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
<Note>
|
|
8
|
-
VSCode extension support is currently buggy. We recommend the [Web
|
|
9
|
-
Debugger](https://bun.com/guides/runtime/web-debugger) for now.
|
|
8
|
+
VSCode extension support is currently buggy. We recommend the [Web Debugger](/docs/guides/runtime/web-debugger) for now.
|
|
10
9
|
</Note>
|
|
11
10
|
|
|
12
11
|
Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-inspector-protocol/src/protocol/jsc/index.d.ts) so you can debug your code with an interactive debugger.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Web debugger
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-
|
|
7
|
+
Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-inspector-protocol/src/protocol/jsc/index.d.ts). To enable debugging when running code with Bun, use the `--inspect` flag. For demonstration purposes, consider the following simple web server.
|
|
8
8
|
|
|
9
9
|
```ts server.ts icon="/icons/typescript.svg"
|
|
10
10
|
Bun.serve({
|
|
@@ -13,4 +13,4 @@ const str = await Bun.readableStreamToArray(stream);
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
See [Docs > API > Utils](
|
|
16
|
+
See [Docs > API > Utils](/docs/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions.
|
|
@@ -13,4 +13,4 @@ const buf = await Bun.readableStreamToArrayBuffer(stream);
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
See [Docs > API > Utils](
|
|
16
|
+
See [Docs > API > Utils](/docs/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions.
|
|
@@ -13,4 +13,4 @@ const blob = await Bun.readableStreamToBlob(stream);
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
See [Docs > API > Utils](
|
|
16
|
+
See [Docs > API > Utils](/docs/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions.
|
|
@@ -14,4 +14,4 @@ const nodeBuf = Buffer.from(arrBuf);
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
See [Docs > API > Utils](
|
|
17
|
+
See [Docs > API > Utils](/docs/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions.
|
|
@@ -13,4 +13,4 @@ const json = await stream.json();
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
See [Docs > API > Utils](
|
|
16
|
+
See [Docs > API > Utils](/docs/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions.
|
|
@@ -13,4 +13,4 @@ const str = await Bun.readableStreamToText(stream);
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
See [Docs > API > Utils](
|
|
16
|
+
See [Docs > API > Utils](/docs/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions.
|
|
@@ -21,4 +21,4 @@ const uint8 = await Bun.readableStreamToBytes(stream);
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
See [Docs > API > Utils](
|
|
24
|
+
See [Docs > API > Utils](/docs/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
title: Selectively run tests concurrently with glob patterns
|
|
3
3
|
sidebarTitle: Concurrent test glob
|
|
4
4
|
mode: center
|
|
5
|
+
description: Set a glob pattern to decide which tests from which files run in parallel
|
|
5
6
|
---
|
|
6
7
|
|
|
7
8
|
This guide demonstrates how to use the `concurrentTestGlob` option to selectively run tests concurrently based on file naming patterns.
|
|
@@ -69,12 +70,14 @@ test("fetch user data", async () => {
|
|
|
69
70
|
expect(response.ok).toBe(true);
|
|
70
71
|
});
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
// can also use test.concurrent() for explicitly marking it as concurrent
|
|
74
|
+
test.concurrent("fetch posts", async () => {
|
|
73
75
|
const response = await fetch("/api/posts");
|
|
74
76
|
expect(response.ok).toBe(true);
|
|
75
77
|
});
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
// can also use test.serial() for explicitly marking it as sequential
|
|
80
|
+
test.serial("fetch comments", async () => {
|
|
78
81
|
const response = await fetch("/api/comments");
|
|
79
82
|
expect(response.ok).toBe(true);
|
|
80
83
|
});
|
|
@@ -64,4 +64,4 @@ coverageThreshold = { lines = 0.5, functions = 0.7 }
|
|
|
64
64
|
|
|
65
65
|
---
|
|
66
66
|
|
|
67
|
-
See [Docs > Test runner > Coverage](
|
|
67
|
+
See [Docs > Test runner > Coverage](/docs/test/code-coverage) for complete documentation on code coverage reporting in Bun.
|
|
@@ -46,4 +46,4 @@ coverage = true # always enable coverage
|
|
|
46
46
|
|
|
47
47
|
---
|
|
48
48
|
|
|
49
|
-
Refer to [Docs > Test runner > Coverage](
|
|
49
|
+
Refer to [Docs > Test runner > Coverage](/docs/test/code-coverage) for complete documentation on code coverage reporting in Bun.
|
|
@@ -70,4 +70,4 @@ Ran 1 tests across 1 files. 1 total [125.00ms]
|
|
|
70
70
|
|
|
71
71
|
---
|
|
72
72
|
|
|
73
|
-
Refer to the [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](
|
|
73
|
+
Refer to the [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](/docs/test/dom) for complete documentation on writing browser tests with Bun.
|
|
@@ -62,7 +62,7 @@ describe("my test suite", () => {
|
|
|
62
62
|
|
|
63
63
|
---
|
|
64
64
|
|
|
65
|
-
Bun implements the vast majority of Jest's matchers, but compatibility isn't 100% yet. Refer to the full compatibility table at [Docs > Test runner > Writing tests](
|
|
65
|
+
Bun implements the vast majority of Jest's matchers, but compatibility isn't 100% yet. Refer to the full compatibility table at [Docs > Test runner > Writing tests](/docs/test/writing-tests#matchers).
|
|
66
66
|
|
|
67
67
|
Some notable missing features:
|
|
68
68
|
|
|
@@ -70,11 +70,11 @@ Some notable missing features:
|
|
|
70
70
|
|
|
71
71
|
---
|
|
72
72
|
|
|
73
|
-
If you're using `testEnvironment: "jsdom"` to run your tests in a browser-like environment, you should follow the [DOM testing with Bun and happy-dom](/guides/test/happy-dom) guide to inject browser APIs into the global scope. This guide relies on [`happy-dom`](https://github.com/capricorn86/happy-dom), which is a leaner and faster alternative to [`jsdom`](https://github.com/jsdom/jsdom).
|
|
73
|
+
If you're using `testEnvironment: "jsdom"` to run your tests in a browser-like environment, you should follow the [DOM testing with Bun and happy-dom](/docs/guides/test/happy-dom) guide to inject browser APIs into the global scope. This guide relies on [`happy-dom`](https://github.com/capricorn86/happy-dom), which is a leaner and faster alternative to [`jsdom`](https://github.com/jsdom/jsdom).
|
|
74
74
|
|
|
75
75
|
At the moment jsdom does not work in Bun due to its internal use of V8 APIs. Track support for it [here](https://github.com/oven-sh/bun/issues/3554).
|
|
76
76
|
|
|
77
|
-
```toml bunfig.toml
|
|
77
|
+
```toml bunfig.toml icon="settings"
|
|
78
78
|
[test]
|
|
79
79
|
preload = ["./happy-dom.ts"]
|
|
80
80
|
```
|
|
@@ -107,11 +107,11 @@ bun test --timeout 10000
|
|
|
107
107
|
|
|
108
108
|
Many other flags become irrelevant or obsolete when using `bun test`.
|
|
109
109
|
|
|
110
|
-
- `transform` — Bun supports TypeScript & JSX. Other file types can be configured with [Plugins](
|
|
110
|
+
- `transform` — Bun supports TypeScript & JSX. Other file types can be configured with [Plugins](/docs/runtime/plugins).
|
|
111
111
|
- `extensionsToTreatAsEsm`
|
|
112
112
|
- `haste` — Bun uses it's own internal source maps
|
|
113
113
|
- `watchman`, `watchPlugins`, `watchPathIgnorePatterns` — use `--watch` to run tests in watch mode
|
|
114
|
-
- `verbose` — set `logLevel: "debug"` in [`bunfig.toml`](
|
|
114
|
+
- `verbose` — set `logLevel: "debug"` in [`bunfig.toml`](/docs/runtime/bunfig#loglevel)
|
|
115
115
|
|
|
116
116
|
---
|
|
117
117
|
|
|
@@ -121,5 +121,5 @@ Settings that aren't mentioned here are not supported or have no equivalent. Ple
|
|
|
121
121
|
|
|
122
122
|
See also:
|
|
123
123
|
|
|
124
|
-
- [Mark a test as a todo](/guides/test/todo-tests)
|
|
125
|
-
- [Docs > Test runner > Writing tests](
|
|
124
|
+
- [Mark a test as a todo](/docs/guides/test/todo-tests)
|
|
125
|
+
- [Docs > Test runner > Writing tests](/docs/test/writing-tests)
|
|
@@ -22,7 +22,7 @@ test("party like it's 1999", () => {
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
The `setSystemTime` function is commonly used on conjunction with [Lifecycle Hooks](
|
|
25
|
+
The `setSystemTime` function is commonly used on conjunction with [Lifecycle Hooks](/docs/test/lifecycle) to configure a testing environment with a deterministic "fake clock".
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
import { test, expect, beforeAll, setSystemTime } from "bun:test";
|
|
@@ -47,4 +47,4 @@ setSystemTime(); // reset to actual time
|
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
-
See [Docs > Test Runner > Date and time](
|
|
50
|
+
See [Docs > Test Runner > Date and time](/docs/test/dates-times) for complete documentation on mocking with the Bun test runner.
|
|
@@ -67,4 +67,4 @@ test("random", async () => {
|
|
|
67
67
|
|
|
68
68
|
---
|
|
69
69
|
|
|
70
|
-
See [Docs > Test Runner > Mocks](
|
|
70
|
+
See [Docs > Test Runner > Mocks](/docs/test/mocks) for complete documentation on mocking with the Bun test runner.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Run tests
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun has a built-in [test runner](
|
|
7
|
+
Bun has a built-in [test runner](/docs/test) with a Jest-like `expect` API.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -113,4 +113,4 @@ Ran 6 tests across 3 files. [59.00ms]
|
|
|
113
113
|
|
|
114
114
|
---
|
|
115
115
|
|
|
116
|
-
See [Docs > Test Runner](
|
|
116
|
+
See [Docs > Test Runner](/docs/test) for complete documentation on the test runner.
|
|
@@ -39,5 +39,5 @@ Ran 3 tests across 1 files. [74.00ms]
|
|
|
39
39
|
|
|
40
40
|
See also:
|
|
41
41
|
|
|
42
|
-
- [Mark a test as a todo](/guides/test/todo-tests)
|
|
43
|
-
- [Docs > Test runner > Writing tests](
|
|
42
|
+
- [Mark a test as a todo](/docs/guides/test/todo-tests)
|
|
43
|
+
- [Docs > Test runner > Writing tests](/docs/test/writing-tests)
|
|
@@ -49,7 +49,7 @@ test
|
|
|
49
49
|
The `snap.test.ts.snap` file is a JavaScript file that exports a serialized version of the value passed into `expect()`. The `{foo: "bar"}` object has been serialized to JSON.
|
|
50
50
|
|
|
51
51
|
```js snap.test.ts.snap icon="file-code"
|
|
52
|
-
// Bun Snapshot v1, https://bun.
|
|
52
|
+
// Bun Snapshot v1, https://bun.com/docs/test/snapshots
|
|
53
53
|
|
|
54
54
|
exports[`snapshot 1`] = `
|
|
55
55
|
{
|
|
@@ -67,7 +67,7 @@ bun test
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
```txt
|
|
70
|
-
bun test v1.3.
|
|
70
|
+
bun test v1.3.3 (9c68abdb)
|
|
71
71
|
test/snap.test.ts:
|
|
72
72
|
✓ snapshot [1.05ms]
|
|
73
73
|
|
|
@@ -86,7 +86,7 @@ bun test --update-snapshots
|
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
```txt
|
|
89
|
-
bun test v1.3.
|
|
89
|
+
bun test v1.3.3 (9c68abdb)
|
|
90
90
|
test/snap.test.ts:
|
|
91
91
|
✓ snapshot [0.86ms]
|
|
92
92
|
|
|
@@ -99,4 +99,4 @@ Ran 1 tests across 1 files. [102.00ms]
|
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
|
-
See [Docs > Test Runner > Snapshots](
|
|
102
|
+
See [Docs > Test Runner > Snapshots](/docs/test/snapshots) for complete documentation on snapshots with the Bun test runner.
|
|
@@ -46,4 +46,4 @@ test("turtles", () => { // [!code ++]
|
|
|
46
46
|
|
|
47
47
|
---
|
|
48
48
|
|
|
49
|
-
See [Docs > Test Runner > Mocks](
|
|
49
|
+
See [Docs > Test Runner > Mocks](/docs/test/mocks) for complete documentation on mocking with the Bun test runner.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Test Svelte
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun's [Plugin API](/runtime/plugins) lets you add custom loaders to your project. The `test.preload` option in `bunfig.toml` lets you configure your loader to start before your tests run.
|
|
7
|
+
Bun's [Plugin API](/docs/runtime/plugins) lets you add custom loaders to your project. The `test.preload` option in `bunfig.toml` lets you configure your loader to start before your tests run.
|
|
8
8
|
|
|
9
9
|
Firstly, install `@testing-library/svelte`, `svelte`, and `@happy-dom/global-registrator`.
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ bun add @testing-library/svelte svelte@4 @happy-dom/global-registrator
|
|
|
14
14
|
|
|
15
15
|
Then, save this plugin in your project.
|
|
16
16
|
|
|
17
|
-
```ts svelte-loader.
|
|
17
|
+
```ts svelte-loader.ts icon="/icons/typescript.svg"
|
|
18
18
|
import { plugin } from "bun";
|
|
19
19
|
import { compile } from "svelte/compiler";
|
|
20
20
|
import { readFileSync } from "fs";
|
|
@@ -61,10 +61,10 @@ Add this to `bunfig.toml` to tell Bun to preload the plugin, so it loads before
|
|
|
61
61
|
```toml bunfig.toml icon="settings"
|
|
62
62
|
[test]
|
|
63
63
|
# Tell Bun to load this plugin before your tests run
|
|
64
|
-
preload = ["./svelte-loader.
|
|
64
|
+
preload = ["./svelte-loader.ts"]
|
|
65
65
|
|
|
66
66
|
# This also works:
|
|
67
|
-
# test.preload = ["./svelte-loader.
|
|
67
|
+
# test.preload = ["./svelte-loader.ts"]
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
---
|
|
@@ -8,7 +8,7 @@ You can use [Testing Library](https://testing-library.com/) with Bun's test runn
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
As a prerequisite to using Testing Library you will need to install [Happy Dom](https://github.com/capricorn86/happy-dom). ([see Bun's Happy DOM guide for more information](
|
|
11
|
+
As a prerequisite to using Testing Library you will need to install [Happy Dom](https://github.com/capricorn86/happy-dom). ([see Bun's Happy DOM guide for more information](/docs/guides/test/happy-dom)).
|
|
12
12
|
|
|
13
13
|
```sh terminal icon="terminal"
|
|
14
14
|
bun add -D @happy-dom/global-registrator
|
|
@@ -24,7 +24,7 @@ bun add -D @testing-library/react @testing-library/dom @testing-library/jest-dom
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
Next you will need to create a preload script for Happy DOM and for Testing Library. For more details about the Happy DOM setup script see [Bun's Happy DOM guide](
|
|
27
|
+
Next you will need to create a preload script for Happy DOM and for Testing Library. For more details about the Happy DOM setup script see [Bun's Happy DOM guide](/docs/guides/test/happy-dom).
|
|
28
28
|
|
|
29
29
|
```ts happydom.ts icon="/icons/typescript.svg"
|
|
30
30
|
import { GlobalRegistrator } from "@happy-dom/global-registrator";
|
|
@@ -90,4 +90,4 @@ test("Can use Testing Library", () => {
|
|
|
90
90
|
|
|
91
91
|
---
|
|
92
92
|
|
|
93
|
-
Refer to the [Testing Library docs](https://testing-library.com/), [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](
|
|
93
|
+
Refer to the [Testing Library docs](https://testing-library.com/), [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](/docs/test/dom) for complete documentation on writing browser tests with Bun.
|
|
@@ -70,5 +70,5 @@ $ echo $?
|
|
|
70
70
|
|
|
71
71
|
See also:
|
|
72
72
|
|
|
73
|
-
- [Skip a test](/guides/test/skip-tests)
|
|
74
|
-
- [Docs > Test runner > Writing tests](
|
|
73
|
+
- [Skip a test](/docs/guides/test/skip-tests)
|
|
74
|
+
- [Docs > Test runner > Writing tests](/docs/test/writing-tests)
|