aboutsummaryrefslogtreecommitdiff
path: root/docs/cli
diff options
context:
space:
mode:
Diffstat (limited to 'docs/cli')
-rw-r--r--docs/cli/bunx.md10
-rw-r--r--docs/cli/create.md26
-rw-r--r--docs/cli/install.md296
-rw-r--r--docs/cli/run.md53
-rw-r--r--docs/cli/test.md219
5 files changed, 158 insertions, 446 deletions
diff --git a/docs/cli/bunx.md b/docs/cli/bunx.md
index 0e6787fc1..fe7bd80a2 100644
--- a/docs/cli/bunx.md
+++ b/docs/cli/bunx.md
@@ -1,8 +1,8 @@
{% callout %}
-**Note** — `bunx` is an alias for `bun x`
+**Note** — `bunx` is an alias for `bun x`. The `bunx` CLI will be auto-installed when you install `bun`.
{% /callout %}
-Use `bunx` to auto-install and run packages from `npm`. The `bunx` CLI will be auto-installed when you install `bun`.
+Use `bunx` to auto-install and run packages from `npm`. It's Bun's equivalent of `npx` or `yarn dlx`.
```bash
$ bunx cowsay "Hello world!"
@@ -50,7 +50,7 @@ $ bunx my-cli --foo bar
## Shebangs
-By default, Bun respects shebangs. If an executable is marked with `#!/usr/bin/env node`, Bun will spin up a `node` process to execute the file. However, in some cases it may be desirable to run executables using [Bun's runtime](/docs/runtime), even if the executable indicates otherwise. To do so, include the `--bun` flag.
+By default, Bun respects shebangs. If an executable is marked with `#!/usr/bin/env node`, Bun will spin up a `node` process to execute the file. However, in some cases it may be desirable to run executables using Bun's runtime, even if the executable indicates otherwise. To do so, include the `--bun` flag.
```bash
$ bunx --bun my-cli
@@ -66,7 +66,7 @@ $ bunx my-cli --bun # bad
{% /callout %}
-## Environment variables
+<!-- ## Environment variables
Bun automatically loads environment variables from `.env` files before running a file, script, or executable. The following files are checked, in order:
@@ -74,4 +74,4 @@ Bun automatically loads environment variables from `.env` files before running a
2. `NODE_ENV` === `"production"` ? `.env.production` : `.env.development`
3. `.env`
-To debug environment variables, run `bun run env` to view a list of resolved environment variables.
+To debug environment variables, run `bun run env` to view a list of resolved environment variables. -->
diff --git a/docs/cli/create.md b/docs/cli/create.md
index a6dc90c2c..393378eed 100644
--- a/docs/cli/create.md
+++ b/docs/cli/create.md
@@ -1,3 +1,29 @@
+## `bun init`
+
+Scaffold an empty project with `bun init`. It's an interactive tool.
+
+```bash
+$ bun init
+bun init helps you get started with a minimal project and tries to
+guess sensible defaults. Press ^C anytime to quit.
+
+package name (quickstart):
+entry point (index.ts):
+
+Done! A package.json file was saved in the current directory.
+ + index.ts
+ + .gitignore
+ + tsconfig.json (for editor auto-complete)
+ + README.md
+
+To get started, run:
+ bun run index.ts
+```
+
+Press `enter` to accept the default answer for each prompt, or pass the `-y` flag to auto-accept the defaults.
+
+## `bun create`
+
Template a new Bun project with `bun create`.
```bash
diff --git a/docs/cli/install.md b/docs/cli/install.md
index 4018a1d19..811c9ec95 100644
--- a/docs/cli/install.md
+++ b/docs/cli/install.md
@@ -1,8 +1,8 @@
-The `bun` CLI contains an `npm`-compatible package manager designed to be a faster replacement for existing package management tools like `npm`, `yarn`, and `pnpm`. It's designed for Node.js compatibility; use it in any Bun or Node.js project.
+The `bun` CLI contains a Node.js-compatible package manager designed to be a dramatically faster replacement for `npm`, `yarn`, and `pnpm`. It's a standalone tool that will work in pre-existing Node.js projects; if your project has a `package.json`, `bun install` can help you speed up your workflow.
{% callout %}
-**⚡️ 80x faster** — Switch from `npm install` to `bun install` in any Node.js project to make your installations up to 80x faster.
+**⚡️ 25x faster** — Switch from `npm install` to `bun install` in any Node.js project to make your installations up to 25x faster.
{% image src="https://user-images.githubusercontent.com/709451/147004342-571b6123-17a9-49a2-8bfd-dcfc5204047e.png" height="200" /%}
@@ -23,7 +23,9 @@ sudo apt install --install-recommends linux-generic-hwe-20.04
{% /details %}
-## Install dependencies
+## Manage dependencies
+
+### `bun install`
To install all dependencies of a project:
@@ -84,13 +86,12 @@ dryRun = false
{% /details %}
-## Add and remove packages
+### `bun add`
-To add or remove a particular package:
+To add a particular package:
```bash
$ bun add preact
-$ bun remove preact
```
To specify a version, version range, or tag:
@@ -147,222 +148,15 @@ To view a complete list of options for a given command:
$ bun add --help
```
-## Git dependencies
+### `bun remove`
-To add a dependency from a git repository:
+To remove a dependency:
```bash
-$ bun install git@github.com:moment/moment.git
-```
-
-Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls), [`git`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies), `git+ssh`, `git+https`, and many more.
-
-```json
-{
- "dependencies": {
- "dayjs": "git+https://github.com/iamkun/dayjs.git",
- "lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
- "moment": "git@github.com:moment/moment.git",
- "zod": "github:colinhacks/zod"
- }
-}
-```
-
-## Global cache
-
-All packages downloaded from the registry are stored in a global cache at `~/.bun/install/cache`. They are stored in subdirectories named like `${name}@${version}`, so multiple versions of a package can be cached.
-
-{% details summary="Configuring cache behavior" %}
-
-```toml
-[install.cache]
-# the directory to use for the cache
-dir = "~/.bun/install/cache"
-
-# when true, don't load from the global cache.
-# Bun may still write to node_modules/.cache
-disable = false
-
-# when true, always resolve the latest versions from the registry
-disableManifest = false
-```
-
-{% /details %}
-
-### Minimizing re-downloads
-
-Bun strives to avoid re-downloading packages mutiple times. When installing a package, if the cache already contains a version in the range specified by `package.json`, Bun will use the cached package instead of downloading it again.
-
-{% details summary="Installation details" %}
-If the semver version has pre-release suffix (`1.0.0-beta.0`) or a build suffix (`1.0.0+20220101`), it is replaced with a hash of that value instead, to reduce the chances of errors associated with long file paths.
-
-When the `node_modules` folder exists, before installing, Bun checks that `node_modules` contains all expected packages with appropriate versions. If so `bun install` completes. Bun uses a custom JSON parser which stops parsing as soon as it finds `"name"` and `"version"`.
-
-If a package is missing or has a version incompatible with the `package.json`, Bun checks for a compatible module in the cache. If found, it is installed into `node_modules`. Otherwise, the package will be downloaded from the registry then installed.
-{% /details %}
-
-### Fast copying
-
-Once a package is downloaded into the cache, Bun still needs to copy those files into `node_modules`. Bun uses the fastest syscalls available to perform this task. On Linux, it uses hardlinks; on macOS, it uses `clonefile`.
-
-### Saving disk space
-
-Since Bun uses hardlinks to "copy" a module into a project's `node_modules` directory on Linux, the contents of the package only exist in a single location on disk, greatly reducing the amount of disk space dedicated to `node_modules`.
-
-This benefit does not extend to macOS, which uses `clonefile` for performance reasons.
-
-{% details summary="Installation strategies" %}
-This behavior is configurable with the `--backend` flag, which is respected by all of Bun's package management commands.
-
-- **`hardlink`**: Default on Linux.
-- **`clonefile`** Default on macOS.
-- **`clonefile_each_dir`**: Similar to `clonefile`, except it clones each file individually per directory. It is only available on macOS and tends to perform slower than `clonefile`.
-- **`copyfile`**: The fallback used when any of the above fail. It is the slowest option. On macOS, it uses `fcopyfile()`; on Linux it uses `copy_file_range()`.
- **`symlink`**: Currently used only `file:` (and eventually `link:`) dependencies. To prevent infinite loops, it skips symlinking the `node_modules` folder.
-
-If you install with `--backend=symlink`, Node.js won't resolve node_modules of dependencies unless each dependency has its own `node_modules` folder or you pass `--preserve-symlinks` to `node`. See [Node.js documentation on `--preserve-symlinks`](https://nodejs.org/api/cli.html#--preserve-symlinks).
-
-```bash
-$ bun install --backend symlink
-$ node --preserve-symlinks ./foo.js
-```
-
-Bun's runtime does not currently expose an equivalent of `--preserve-symlinks`.
-{% /details %}
-
-## Lockfile
-
-Running `bun install` will create a binary lockfile called `bun.lockb`.
-
-#### Why is it binary?
-
-In a word: Performance. Bun’s lockfile saves & loads incredibly quickly, and saves a lot more data than what is typically inside lockfiles.
-
-#### How do I inspect it?
-
-Run `bun install -y` to generate a Yarn-compatible `yarn.lock` (v1) that can be inspected more easily.
-
-#### Platform-specific dependencies?
-
-Bun stores normalized `cpu` and `os` values from npm in the lockfile, along with the resolved packages. It skips downloading, extracting, and installing packages disabled for the current target at runtime. This means the lockfile won’t change between platforms/architectures even if the packages ultimately installed do change.
-
-#### What does the lockfile store?
-
-Packages, metadata for those packages, the hoisted install order, dependencies for each package, what packages those dependencies resolved to, an integrity hash (if available), what each package was resolved to, and which version (or equivalent).
-
-#### Why is it fast?
-
-It uses linear arrays for all data. [Packages](https://github.com/oven-sh/bun/blob/be03fc273a487ac402f19ad897778d74b6d72963/src/install/install.zig#L1825) are referenced by an auto-incrementing integer ID or a hash of the package name. Strings longer than 8 characters are de-duplicated. Prior to saving on disk, the lockfile is garbage-collected & made deterministic by walking the package tree and cloning the packages in dependency order.
-
-#### Can I opt out?
-
-To install without creating a lockfile:
-
-```bash
-$ bun install --no-save
-```
-
-To install a Yarn lockfile _in addition_ to `bun.lockb`.
-
-{% codetabs %}
-
-```bash#CLI flag
-$ bun install --yarn
-```
-
-```toml#bunfig.toml
-[install.lockfile]
-# whether to save a non-Bun lockfile alongside bun.lockb
-# only "yarn" is supported
-print = "yarn"
-```
-
-{% /codetabs %}
-
-{% details summary="Configuring lockfile" %}
-
-```toml
-[install.lockfile]
-
-# path to read bun.lockb from
-path = "bun.lockb"
-
-# path to save bun.lockb to
-savePath = "bun.lockb"
-
-# whether to save the lockfile to disk
-save = true
-
-# whether to save a non-Bun lockfile alongside bun.lockb
-# only "yarn" is supported
-print = "yarn"
-```
-
-{% /details %}
-
-## Workspaces
-
-Bun supports [`workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspaces?v=true#description) in `package.json`. Workspaces make it easy to develop complex software as a _monorepo_ consisting of several independent packages.
-
-To try it, specify a list of sub-packages in the `workspaces` field of your `package.json`; it's conventional to place these sub-packages in a directory called `packages`.
-
-```json
-{
- "name": "my-project",
- "version": "1.0.0",
- "workspaces": ["packages/*"]
-}
-```
-
-{% callout %}
-**Glob support** — Bun v0.5.8 added support for simple globs for workspace names, with a "*/" at the end. Nothing too fancy.
-{% /callout %}
-
-This has a couple major benefits.
-
-- **Code can be split into logical parts.** If one package relies on another, you can simply add it as a dependency with `bun add`. If package `b` depends on `a`, `bun install` will symlink your local `packages/a` directory into the `node_modules` folder of `b`, instead of trying to download it from the npm registry.
-- **Dependencies can be de-duplicated.** If `a` and `b` share a common dependency, it will be _hoisted_ to the root `node_modules` directory. This reduces redundant disk usage and minimizes "dependency hell" issues associated with having multiple versions of a package installed simultaneously.
-
-{% callout %}
-⚡️ **Speed** — Installs are fast, even for big monorepos. Bun installs the [Remix](https://github.com/remix-run/remix) monorepo in about `500ms` on Linux.
-
-- 28x faster than `npm install`
-- 12x faster than `yarn install` (v1)
-- 8x faster than `pnpm install`
-
-{% image src="https://user-images.githubusercontent.com/709451/212829600-77df9544-7c9f-4d8d-a984-b2cd0fd2aa52.png" /%}
-{% /callout %}
-
-## Registries
-
-The default registry is `registry.npmjs.org`. This can be globally configured in `bunfig.toml`:
-
-```toml
-[install]
-# set default registry as a string
-registry = "https://registry.npmjs.org"
-# set a token
-registry = { url = "https://registry.npmjs.org", token = "123456" }
-# set a username/password
-registry = "https://username:password@registry.npmjs.org"
-```
-
-To configure a private registry scoped to a particular organization:
-
-```toml
-[install.scopes]
-# registry as string
-"@myorg1" = "https://username:password@registry.myorg.com/"
-
-# registry with username/password
-# you can reference environment variables
-"@myorg2" = { username = "myusername", password = "$NPM_PASS", url = "https://registry.myorg.com/" }
-
-# registry with token
-"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
+$ bun remove preact
```
-## Linking and unlinking
+## Local packages (`bun link`)
Use `bun link` in a local directory to register the current package as a "linkable" package.
@@ -403,44 +197,56 @@ This will add `cool-pkg` to the `dependencies` field of your app's package.json
}
```
-## Utilities
-
-The `bun pm` command group provides a set of utilities for working with Bun's package manager.
+## Git dependencies
-To print the path to the `bin` directory for the local project:
+To add a dependency from a git repository:
```bash
-$ bun pm bin
-/path/to/current/project/node_modules/.bin
+$ bun install git@github.com:moment/moment.git
```
-To get the path to the global `bin` directory:
+Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls), [`git`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies), `git+ssh`, `git+https`, and many more.
-```bash
-$ bun pm bin
-<$HOME>/.bun/bin
+```json
+{
+ "dependencies": {
+ "dayjs": "git+https://github.com/iamkun/dayjs.git",
+ "lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
+ "moment": "git@github.com:moment/moment.git",
+ "zod": "github:colinhacks/zod"
+ }
+}
```
-To print a list of packages installed in the current project and their resolved versions, excluding their dependencies. Use the `--all` flag to print the entire tree, including all nth-order dependencies.
+## Tarball dependencies
-```bash
-$ bun pm ls
-/path/to/project node_modules (5)
-├── eslint@8.33.0
-├── react@18.2.0
-├── react-dom@18.2.0
-├── typescript@4.8.4
-└── zod@3.20.1
-```
+A package name can correspond to a publically hosted `.tgz` file. During `bun install`, Bun will download and install the package from the specified tarball URL, rather than from the package registry.
-To print the path to Bun's global module cache:
-
-```bash
-$ bun pm cache
+```json#package.json
+{
+ "dependencies": {
+ "zod": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz"
+ }
+}
```
-To clear Bun's global module cache:
-
-```bash
-$ bun pm cache rm
+## CI/CD
+
+Looking to speed up your CI? Use the official `oven-sh/setup-bun` action to install `bun` in a GitHub Actions pipeline.
+
+```yaml#.github/workflows/release.yml
+name: bun-types
+jobs:
+ build:
+ name: build-app
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repo
+ uses: actions/checkout@v3
+ - name: Install bun
+ uses: oven-sh/setup-bun@v1
+ - name: Install dependencies
+ run: bun install
+ - name: Build app
+ run: bun run build
```
diff --git a/docs/cli/run.md b/docs/cli/run.md
index 133f3e1ec..7a5f8e9d2 100644
--- a/docs/cli/run.md
+++ b/docs/cli/run.md
@@ -1,31 +1,38 @@
The `bun` CLI can be used to execute JavaScript/TypeScript files, `package.json` scripts, and [executable packages](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#bin).
-## Running a file
+<!-- ## Speed -->
+
+<!--
+Performance sensitive APIs like `Buffer`, `fetch`, and `Response` are heavily profiled and optimized. Under the hood Bun uses the [JavaScriptCore engine](https://developer.apple.com/documentation/javascriptcore), which is developed by Apple for Safari. It starts and runs faster than V8, the engine used by Node.js and Chromium-based browsers. -->
+
+## Run a file
{% callout %}
Compare to `node <file>`
{% /callout %}
-Bun can execute `.js`, `.jsx`, `.ts`, and `.tsx` files. Every file is transpiled to vanilla JavaScript by Bun's fast native transpiler before being executed. For details on Bun's runtime, refer to the [Bun runtime](/docs/runtime) documentation.
+Use `bun run` to execute a source file.
-```ts#foo.ts
-import { z } from "zod";
-
-const schema = z.string()
-const result = schema.parse("Billie Eilish");
-console.log(result);
+```bash
+$ bun run index.js
```
-To run a file in Bun:
+Bun supports TypeScript and JSX out of the box. Every file is transpiled on the fly by Bun's fast native transpiler before being executed.
```bash
-$ bun foo.ts
-Billie Eilish
+$ bun run index.js
+$ bun run index.jsx
+$ bun run index.ts
+$ bun run index.tsx
```
-If no `node_modules` directory is found in the working directory or above, Bun will abandon Node.js-style module resolution in favor of the `Bun module resolution algorithm`. Under Bun-style module resolution, all packages are _auto-installed_ on the fly into a [global module cache](/docs/cli/install#global-cache). For full details on this algorithm, refer to [Runtime > Modules](/docs/runtime/modules).
+The "naked" `bun` command is equivalent to `bun run`.
-## Running a package script
+```bash
+$ bun index.tsx
+```
+
+## Run a `package.json` script
{% note %}
Compare to `npm run <script>` or `yarn <script>`
@@ -80,3 +87,23 @@ quickstart scripts:
```
Bun respects lifecycle hooks. For instance, `bun run clean` will execute `preclean` and `postclean`, if defined. If the `pre<script>` fails, Bun will not execute the script itself.
+
+## Environment variables
+
+Bun automatically loads environment variables from `.env` files before running a file, script, or executable. The following files are checked, in order:
+
+1. `.env.local` (first)
+2. `NODE_ENV` === `"production"` ? `.env.production` : `.env.development`
+3. `.env`
+
+To debug environment variables, run `bun run env` to view a list of resolved environment variables.
+
+## Performance
+
+Bun is designed to start fast and run fast.
+
+Under the hood Bun uses the [JavaScriptCore engine](https://developer.apple.com/documentation/javascriptcore), which is developed by Apple for Safari. In most cases, the startup and running performance is faster than V8, the engine used by Node.js and Chromium-based browsers. It's transpiler and runtime are written in Zig, a modern, high-performance language. On Linux, this translates into startup times [4x faster](https://twitter.com/jarredsumner/status/1499225725492076544) than Node.js.
+
+{% image src="/images/bun-run-speed.jpeg" caption="Bun vs Node.js vs Deno running Hello World" /%}
+
+<!-- If no `node_modules` directory is found in the working directory or above, Bun will abandon Node.js-style module resolution in favor of the `Bun module resolution algorithm`. Under Bun-style module resolution, all packages are _auto-installed_ on the fly into a [global module cache](/docs/cli/install#global-cache). For full details on this algorithm, refer to [Runtime > Modules](/docs/runtime/modules). -->
diff --git a/docs/cli/test.md b/docs/cli/test.md
index 2ac4cf208..ecae45377 100644
--- a/docs/cli/test.md
+++ b/docs/cli/test.md
@@ -1,10 +1,12 @@
Bun ships with a built-in test runner.
+## Run tests
+
```bash
$ bun test
```
-Tests are written in JavaScript or TypeScript with a Jest-like API.
+Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to [Writing tests](/docs/test/writing) for full documentation.
```ts#math.test.ts
import { expect, test } from "bun:test";
@@ -14,10 +16,6 @@ test("2 + 2", () => {
});
```
-It's fast.
-
-{% image src="/images/buntest.jpeg" caption="Bun runs 266 React SSR tests faster than Jest can print its version number." /%}
-
The runner recursively searches the working directory for files that match the following patterns:
- `*.test.{js|jsx|ts|tsx}`
@@ -31,208 +29,63 @@ You can filter the set of tests to run by passing additional positional argument
$ bun test <filter> <filter> ...
```
-<!--
-Consider the following directory structure:
+## Snapshot testing
-```
-.
-├── a.test.ts
-├── b.test.ts
-├── c.test.ts
-└── foo
- ├── a.test.ts
- └── b.test.ts
-```
+Snapshots are supported by `bun test`. First, write a test using the `.toMatchSnapshot()` matcher:
-To run both `a.test.ts` files:
+```ts
+import { test, expect } from "bun:test";
-```
-$ bun test a
+test("snap", () => {
+ expect("foo").toMatchSnapshot();
+});
```
-To run all tests in the `foo` directory:
+Then generate snapshots with the following command:
+```bash
+bun test --update-snapshots
```
-$ bun test foo
-```
-
-Any test file in the directory with an _absolute path_ that contains one of the targets will run. Glob patterns are not yet supported. -->
-## Writing tests
+Snapshots will be stored in a `__snapshots__` directory next to the test file.
-Define tests with a Jest-like API imported from the built-in `bun:test` module.
+## Watch mode
-```ts#math.test.ts
-import { expect, test } from "bun:test";
+Similar to `bun run`, you can pass the `--watch` flag to `bun test` to watch for changes and re-run tests.
-test("2 + 2", () => {
- expect(2 + 2).toBe(4);
-});
+```bash
+$ bun test --watch
```
-Group tests into suites with `describe`.
-
-```ts#math.test.ts
-import { expect, test, describe } from "bun:test";
+## Performance
-describe("arithmetic", () => {
- test("2 + 2", () => {
- expect(2 + 2).toBe(4);
- });
-
- test("2 * 2", () => {
- expect(2 * 2).toBe(4);
- });
-});
-```
+Bun's test runner is fast.
-Tests can be `async`.
+{% image src="/images/buntest.jpeg" caption="Running 266 React SSR tests faster than Jest can print its version number." /%}
-```ts
-import { expect, test } from "bun:test";
+<!--
+Consider the following directory structure:
-test("2 * 2", async () => {
- const result = await Promise.resolve(2 * 2);
- expect(result).toEqual(4);
-});
```
-
-Alternatively, use the `done` callback to signal completion. If you include the `done` callback as a parameter in your test definition, you _must_ call it or the test will hang.
-
-```ts
-import { expect, test } from "bun:test";
-
-test("2 * 2", done => {
- Promise.resolve(2 * 2).then(result => {
- expect(result).toEqual(4);
- done();
- });
-});
+.
+├── a.test.ts
+├── b.test.ts
+├── c.test.ts
+└── foo
+ ├── a.test.ts
+ └── b.test.ts
```
-Perform per-test setup and teardown logic with `beforeEach` and `afterEach`.
-
-```ts
-import { expect, test } from "bun:test";
-
-beforeEach(() => {
- console.log("running test.");
-});
-
-afterEach(() => {
- console.log("done with test.");
-});
+To run both `a.test.ts` files:
-// tests...
```
-
-Perform per-scope setup and teardown logic with `beforeAll` and `afterAll`. At the top-level, the _scope_ is the current file; in a `describe` block, the scope is the block itself.
-
-```ts
-import { expect, test, beforeAll, afterAll } from "bun:test";
-
-let db: Database;
-beforeAll(() => {
- // connect to database
-});
-
-afterAll(() => {
- // close connection
-});
-
-// tests...
+$ bun test a
```
-Skip individual tests with `test.skip`.
-
-```ts
-import { expect, test } from "bun:test";
+To run all tests in the `foo` directory:
-test.skip("wat", () => {
- // TODO: fix this
- expect(0.1 + 0.2).toEqual(0.3);
-});
+```
+$ bun test foo
```
-## Expect matchers
-
-Bun implements the following matchers. Full Jest compatibility is on the roadmap; track progress [here](https://github.com/oven-sh/bun/issues/1825).
-
-- [x] [`.not`](https://jestjs.io/docs/expect#not)
-- [x] [`.toBe()`](https://jestjs.io/docs/expect#tobevalue)
-- [x] [`.toEqual()`](https://jestjs.io/docs/expect#toequalvalue)
-- [x] [`.toBeNull()`](https://jestjs.io/docs/expect#tobenull)
-- [x] [`.toBeUndefined()`](https://jestjs.io/docs/expect#tobeundefined)
-- [x] [`.toBeNaN()`](https://jestjs.io/docs/expect#tobenan)
-- [x] [`.toBeDefined()`](https://jestjs.io/docs/expect#tobedefined)
-- [x] [`.toBeFalsy()`](https://jestjs.io/docs/expect#tobefalsy)
-- [x] [`.toBeTruthy()`](https://jestjs.io/docs/expect#tobetruthy)
-- [x] [`.toContain()`](https://jestjs.io/docs/expect#tocontainitem)
-- [x] [`.toStrictEqual()`](https://jestjs.io/docs/expect#tostrictequalvalue)
-- [x] [`.toThrow()`](https://jestjs.io/docs/expect#tothrowerror)
-- [x] [`.toHaveLength()`](https://jestjs.io/docs/expect#tohavelengthnumber)
-- [x] [`.toHaveProperty()`](https://jestjs.io/docs/expect#tohavepropertykeypath-value)
-- [ ] [`.extend`](https://jestjs.io/docs/expect#expectextendmatchers)
-- [ ] [`.anything()`](https://jestjs.io/docs/expect#expectanything)
-- [ ] [`.any()`](https://jestjs.io/docs/expect#expectanyconstructor)
-- [ ] [`.arrayContaining()`](https://jestjs.io/docs/expect#expectarraycontainingarray)
-- [ ] [`.assertions()`](https://jestjs.io/docs/expect#expectassertionsnumber)
-- [ ] [`.closeTo()`](https://jestjs.io/docs/expect#expectclosetonumber-numdigits)
-- [ ] [`.hasAssertions()`](https://jestjs.io/docs/expect#expecthasassertions)
-- [ ] [`.objectContaining()`](https://jestjs.io/docs/expect#expectobjectcontainingobject)
-- [ ] [`.stringContaining()`](https://jestjs.io/docs/expect#expectstringcontainingstring)
-- [ ] [`.stringMatching()`](https://jestjs.io/docs/expect#expectstringmatchingstring--regexp)
-- [ ] [`.addSnapshotSerializer()`](https://jestjs.io/docs/expect#expectaddsnapshotserializerserializer)
-- [ ] [`.resolves()`](https://jestjs.io/docs/expect#resolves)
-- [ ] [`.rejects()`](https://jestjs.io/docs/expect#rejects)
-- [ ] [`.toHaveBeenCalled()`](https://jestjs.io/docs/expect#tohavebeencalled)
-- [ ] [`.toHaveBeenCalledTimes()`](https://jestjs.io/docs/expect#tohavebeencalledtimesnumber)
-- [ ] [`.toHaveBeenCalledWith()`](https://jestjs.io/docs/expect#tohavebeencalledwitharg1-arg2-)
-- [ ] [`.toHaveBeenLastCalledWith()`](https://jestjs.io/docs/expect#tohavebeenlastcalledwitharg1-arg2-)
-- [ ] [`.toHaveBeenNthCalledWith()`](https://jestjs.io/docs/expect#tohavebeennthcalledwithnthcall-arg1-arg2-)
-- [ ] [`.toHaveReturned()`](https://jestjs.io/docs/expect#tohavereturned)
-- [ ] [`.toHaveReturnedTimes()`](https://jestjs.io/docs/expect#tohavereturnedtimesnumber)
-- [ ] [`.toHaveReturnedWith()`](https://jestjs.io/docs/expect#tohavereturnedwithvalue)
-- [ ] [`.toHaveLastReturnedWith()`](https://jestjs.io/docs/expect#tohavelastreturnedwithvalue)
-- [ ] [`.toHaveNthReturnedWith()`](https://jestjs.io/docs/expect#tohaventhreturnedwithnthcall-value)
-- [ ] [`.toBeCloseTo()`](https://jestjs.io/docs/expect#tobeclosetonumber-numdigits)
-- [x] [`.toBeGreaterThan()`](https://jestjs.io/docs/expect#tobegreaterthannumber--bigint)
-- [x] [`.toBeGreaterThanOrEqual()`](https://jestjs.io/docs/expect#tobegreaterthanorequalnumber--bigint)
-- [x] [`.toBeLessThan()`](https://jestjs.io/docs/expect#tobelessthannumber--bigint)
-- [x] [`.toBeLessThanOrEqual()`](https://jestjs.io/docs/expect#tobelessthanorequalnumber--bigint)
-- [x] [`.toBeInstanceOf()`](https://jestjs.io/docs/expect#tobeinstanceofclass) (Bun v0.5.8+)
-- [ ] [`.toContainEqual()`](https://jestjs.io/docs/expect#tocontainequalitem)
-- [ ] [`.toMatch()`](https://jestjs.io/docs/expect#tomatchregexp--string)
-- [ ] [`.toMatchObject()`](https://jestjs.io/docs/expect#tomatchobjectobject)
-- [x] [`.toMatchSnapshot()`](https://jestjs.io/docs/expect#tomatchsnapshotpropertymatchers-hint) (Bun v0.5.8+)
-- [ ] [`.toMatchInlineSnapshot()`](https://jestjs.io/docs/expect#tomatchinlinesnapshotpropertymatchers-inlinesnapshot)
-- [ ] [`.toThrowErrorMatchingSnapshot()`](https://jestjs.io/docs/expect#tothrowerrormatchingsnapshothint)
-- [ ] [`.toThrowErrorMatchingInlineSnapshot()`](https://jestjs.io/docs/expect#tothrowerrormatchinginlinesnapshotinlinesnapshot)
-
-<!-- ```ts
-test('matchers', ()=>{
-
- expect(5).toBe(5);
- expect("do re mi").toContain("mi");
- expect("do re mi").toEqual("do re mi");
- expect({}).toStrictEqual({}); // uses Bun.deepEquals()
- expect([1,2,3]).toHaveLength(3);
- expect({ name: "foo" }).toHaveProperty("name");
- expect({ name: "foo" }).toHaveProperty("name", "foo");
- expect(5).toBeTruthy();
- expect(0).toBeFalsy();
- expect("").toBeDefined();
- expect(undefined).toBeUndefined();
- expect(parseInt('tuna')).toBeNaN();
- expect(null).toBeNull();
- expect(5).toBeGreaterThan(4);
- expect(5).toBeGreaterThanOrEqual(5);
- expect(5).toBeLessThan(6);
- expect(5).toBeLessThanOrEqual(5);
- expect(()=>throw new Error()).toThrow();
-
- // negation
- expect(5).not.toBe(4)
-
-})
-``` -->
+Any test file in the directory with an _absolute path_ that contains one of the targets will run. Glob patterns are not yet supported. -->