From 263382103f47ce6f7063ad07d34664718b4c1ea7 Mon Sep 17 00:00:00 2001 From: Samuel Rigaud <46346622+s-rigaud@users.noreply.github.com> Date: Tue, 12 Sep 2023 21:50:05 -0400 Subject: docs: fix typos (#5151) --- docs/cli/bundler.md | 2 +- docs/cli/install.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/cli') diff --git a/docs/cli/bundler.md b/docs/cli/bundler.md index 6900e9292..1b4c419c1 100644 --- a/docs/cli/bundler.md +++ b/docs/cli/bundler.md @@ -1,6 +1,6 @@ Bundling is currently an important mechanism for building complex web apps. -Modern apps typically consist of a large number of files and package dependencies. Despite the fact that modern browsers support [ES Module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) imports, it's still too slow to fetch each file via inidividual HTTP requests. _Bundling_ is the process of concatenating several source files into a single large file that can be loaded in a single request. +Modern apps typically consist of a large number of files and package dependencies. Despite the fact that modern browsers support [ES Module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) imports, it's still too slow to fetch each file via individual HTTP requests. _Bundling_ is the process of concatenating several source files into a single large file that can be loaded in a single request. {% callout %} **On bundling** — Despite recent advances like [`modulepreload`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/modulepreload) and [HTTP/3](https://en.wikipedia.org/wiki/HTTP/3), bundling is still the most performant approach. diff --git a/docs/cli/install.md b/docs/cli/install.md index a608a8950..34478a771 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -289,7 +289,7 @@ Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com ## Tarball dependencies -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. +A package name can correspond to a publicly hosted `.tgz` file. During `bun install`, Bun will download and install the package from the specified tarball URL, rather than from the package registry. ```json#package.json { -- cgit v1.2.3 From 15f7bacb8bd57615475e1614f5f93b23810e63b1 Mon Sep 17 00:00:00 2001 From: Nathan Hammond Date: Wed, 13 Sep 2023 16:19:15 +0800 Subject: Correct the configuration file names. (#5234) --- docs/cli/install.md | 2 +- docs/install/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/cli') diff --git a/docs/cli/install.md b/docs/cli/install.md index 34478a771..beaf6ca47 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -69,7 +69,7 @@ $ bun install --silent # no logging ``` {% details summary="Configuring behavior" %} -The default behavior of `bun install` can be configured in `bun.toml`: +The default behavior of `bun install` can be configured in `bunfig.toml`: ```toml [install] diff --git a/docs/install/index.md b/docs/install/index.md index 219e22d4c..11e0d4fd4 100644 --- a/docs/install/index.md +++ b/docs/install/index.md @@ -69,7 +69,7 @@ $ bun install --silent # no logging ``` {% details summary="Configuring behavior" %} -The default behavior of `bun install` can be configured in `bun.toml`: +The default behavior of `bun install` can be configured in `bunfig.toml`: ```toml [install] -- cgit v1.2.3 From cb01cb0d4ad67aace33ae603938d1a28a7c10ca7 Mon Sep 17 00:00:00 2001 From: James Gordo <14321895+jamesgordo@users.noreply.github.com> Date: Thu, 14 Sep 2023 07:36:11 +0800 Subject: Fixed api & cli docs typo. (#5262) * Fixed api & cli docs typo. * Fix --------- Co-authored-by: Colin McDonnell --- docs/api/http.md | 2 +- docs/api/workers.md | 4 ++-- docs/cli/bun-install.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/cli') diff --git a/docs/api/http.md b/docs/api/http.md index 629570335..cd20a9931 100644 --- a/docs/api/http.md +++ b/docs/api/http.md @@ -71,7 +71,7 @@ In development mode, Bun will surface errors in-browser with a built-in error pa {% image src="/images/exception_page.png" caption="Bun's built-in 500 page" /%} -To handle server-side errors, implement an `error` handler. This function should return a `Response` to served to the client when an error occurs. This response will supercede Bun's default error page in `development` mode. +To handle server-side errors, implement an `error` handler. This function should return a `Response` to serve to the client when an error occurs. This response will supersede Bun's default error page in `development` mode. ```ts Bun.serve({ diff --git a/docs/api/workers.md b/docs/api/workers.md index 1a4a09965..50fdb9c3d 100644 --- a/docs/api/workers.md +++ b/docs/api/workers.md @@ -130,7 +130,7 @@ const worker = new Worker(new URL("worker.ts", import.meta.url).href); worker.unref(); ``` -Note: `worker.unref()` is not available in browers. +Note: `worker.unref()` is not available in browsers. ### `worker.ref()` @@ -151,7 +151,7 @@ const worker = new Worker(new URL("worker.ts", import.meta.url).href, { }); ``` -Note: `worker.ref()` is not available in browers. +Note: `worker.ref()` is not available in browsers. ## Memory usage with `smol` diff --git a/docs/cli/bun-install.md b/docs/cli/bun-install.md index 8050070be..e705a2172 100644 --- a/docs/cli/bun-install.md +++ b/docs/cli/bun-install.md @@ -47,7 +47,7 @@ registry = "https://registry.yarnpkg.com/" # Install for production? This is the equivalent to the "--production" CLI argument production = false -# Disallow changes to lockfile? This is the equivalent to the "--fozen-lockfile" CLI argument +# Disallow changes to lockfile? This is the equivalent to the "--frozen-lockfile" CLI argument frozenLockfile = false # Don't actually install -- cgit v1.2.3 From 8ae9aeea6becd8e34c45885943cfe3643beb68c9 Mon Sep 17 00:00:00 2001 From: Nathan Hammond Date: Thu, 14 Sep 2023 13:32:03 +0800 Subject: Remove the ability to configure lockfile. (#5335) --- completions/bun.bash | 6 +++--- completions/bun.zsh | 8 +------- completions/spec.yaml | 9 --------- docs/cli/bun-install.md | 9 --------- docs/install/lockfile.md | 6 ------ docs/runtime/configuration.md | 6 ------ src/bunfig.zig | 12 ------------ src/install/install.zig | 33 ++------------------------------- 8 files changed, 6 insertions(+), 83 deletions(-) (limited to 'docs/cli') diff --git a/completions/bun.bash b/completions/bun.bash index 499adc470..e77f80db5 100644 --- a/completions/bun.bash +++ b/completions/bun.bash @@ -92,12 +92,12 @@ _bun_completions() { PACKAGE_OPTIONS[REMOVE_OPTIONS_LONG]=""; PACKAGE_OPTIONS[REMOVE_OPTIONS_SHORT]=""; - PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help"; + PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --frozen-lockfile --no-save --dry-run --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help"; PACKAGE_OPTIONS[SHARED_OPTIONS_SHORT]="-c -y -p -f -g"; - PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help" + PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --frozen-lockfile --no-save --dry-run --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help" PM_OPTIONS[SHORT_OPTIONS]="-c -y -p -f -g" - + local cur_word="${COMP_WORDS[${COMP_CWORD}]}"; local prev="${COMP_WORDS[$(( COMP_CWORD - 1 ))]}"; diff --git a/completions/bun.zsh b/completions/bun.zsh index 59df1db47..6f3665652 100644 --- a/completions/bun.zsh +++ b/completions/bun.zsh @@ -55,7 +55,6 @@ _bun() { '--no-save[]' \ '--dry-run[Don'"'"'t install anything]' \ '--force[Always request the latest versions from the registry & reinstall all dependenices]' \ - '--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \ '--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \ '--no-cache[Ignore manifest cache entirely]' \ '--silent[Don'"'"'t output anything]' \ @@ -97,7 +96,6 @@ _bun() { '--no-save[]' \ '--dry-run[Don'"'"'t install anything]' \ '--force[Always request the latest versions from the registry & reinstall all dependenices]' \ - '--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \ '--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \ '--no-cache[Ignore manifest cache entirely]' \ '--silent[Don'"'"'t output anything]' \ @@ -133,7 +131,6 @@ _bun() { '--no-save[]' \ '--dry-run[Don'"'"'t install anything]' \ '--force[Always request the latest versions from the registry & reinstall all dependenices]' \ - '--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \ '--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \ '--no-cache[Ignore manifest cache entirely]' \ '--silent[Don'"'"'t output anything]' \ @@ -284,7 +281,6 @@ _bun() { '--frozen-lockfile[Disallow changes to lockfile]' \ '--no-save[Do not save a lockfile]' '--dry-run[Do not install anything]' - '--lockfile[Store & load a lockfile at a specific filepath]' '-f[Always request the latest versions from the registry & reinstall all dependencies]' '--force[Always request the latest versions from the registry & reinstall all dependencies]' '--cache-dir[Store & load cached data from a specific directory path]' @@ -540,7 +536,6 @@ _bun() { '--no-save[]' \ '--dry-run[Don'"'"'t install anything]' \ '--force[Always request the latest versions from the registry & reinstall all dependenices]' \ - '--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \ '--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \ '--no-cache[Ignore manifest cache entirely]' \ '--silent[Don'"'"'t output anything]' \ @@ -576,7 +571,6 @@ _bun() { '-g[Remove a package globally]' \ '--global[Remove a package globally]' \ '--force[Always request the latest versions from the registry & reinstall all dependenices]' \ - '--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \ '--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \ '--no-cache[Ignore manifest cache entirely]' \ '--silent[Don'"'"'t output anything]' \ @@ -642,7 +636,7 @@ _bun_run_param_script_completion() { local -a scripts_list IFS=$'\n' scripts_list=($(SHELL=zsh bun getcompletes s)) IFS=$'\n' bins=($(SHELL=zsh bun getcompletes b)) - + _alternative "scripts:scripts:(($scripts_list))" _alternative "bin:bin:(($bins))" _alternative "files:file:_files -g '*.(js|ts|jsx|tsx|wasm)'" diff --git a/completions/spec.yaml b/completions/spec.yaml index c3391c192..a07c5c797 100644 --- a/completions/spec.yaml +++ b/completions/spec.yaml @@ -119,9 +119,6 @@ subcommands: - no-save -- - dry-run -- "Don't install anything" - force -- "Always request the latest versions from the registry & reinstall all dependenices" - - name: lockfile - type: string - summary: "Store & load a lockfile at a specific filepath" - name: cache-dir type: string summary: "Store & load cached data from a specific directory path" @@ -160,9 +157,6 @@ subcommands: - no-cache -- "Ignore manifest cache entirely" - silent -- "Don't output anything" - verbose -- "Excessively verbose logging" - - name: lockfile - type: string - summary: "Store & load a lockfile at a specific filepath" - name: cache-dir type: string summary: "Store & load cached data from a specific directory path" @@ -198,9 +192,6 @@ subcommands: - no-save -- - dry-run -- "Don't install anything" - force -- "Always request the latest versions from the registry & reinstall all dependenices" - - name: lockfile - type: string - summary: "Store & load a lockfile at a specific filepath" - name: cache-dir type: string summary: "Store & load cached data from a specific directory path" diff --git a/docs/cli/bun-install.md b/docs/cli/bun-install.md index e705a2172..3efe2da7f 100644 --- a/docs/cli/bun-install.md +++ b/docs/cli/bun-install.md @@ -89,12 +89,6 @@ disableManifest = false # Note: it does not load the lockfile, it just converts bun.lockb into a yarn.lock print = "yarn" -# Path to read bun.lockb from -path = "bun.lockb" - -# Path to save bun.lockb to -savePath = "bun.lockb" - # Save the lockfile to disk save = true @@ -142,8 +136,6 @@ export interface Cache { export interface Lockfile { print?: "yarn"; - path: string; - savePath: string; save: boolean; } ``` @@ -156,7 +148,6 @@ Environment variables have a higher priority than `bunfig.toml`. | -------------------------------- | ------------------------------------------------------------- | | BUN_CONFIG_REGISTRY | Set an npm registry (default: ) | | BUN_CONFIG_TOKEN | Set an auth token (currently does nothing) | -| BUN_CONFIG_LOCKFILE_SAVE_PATH | File path to save the lockfile to (default: bun.lockb) | | BUN_CONFIG_YARN_LOCKFILE | Save a Yarn v1-style yarn.lock | | BUN_CONFIG_LINK_NATIVE_BINS | Point `bin` in package.json to a platform-specific dependency | | BUN_CONFIG_SKIP_SAVE_LOCKFILE | Don’t save a lockfile | diff --git a/docs/install/lockfile.md b/docs/install/lockfile.md index c7306c1b9..f8e3001ca 100644 --- a/docs/install/lockfile.md +++ b/docs/install/lockfile.md @@ -79,12 +79,6 @@ print = "yarn" ```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 diff --git a/docs/runtime/configuration.md b/docs/runtime/configuration.md index df2fc5199..d7a1d386d 100644 --- a/docs/runtime/configuration.md +++ b/docs/runtime/configuration.md @@ -148,12 +148,6 @@ To configure lockfile behavior: # 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" diff --git a/src/bunfig.zig b/src/bunfig.zig index 76f33cb82..02825d2b5 100644 --- a/src/bunfig.zig +++ b/src/bunfig.zig @@ -392,18 +392,6 @@ pub const Bunfig = struct { install.save_lockfile = value; } } - - if (lockfile_expr.get("path")) |lockfile| { - if (lockfile.asString(allocator)) |value| { - install.lockfile_path = value; - } - } - - if (lockfile_expr.get("savePath")) |lockfile| { - if (lockfile.asString(allocator)) |value| { - install.save_lockfile_path = value; - } - } } if (_bun.get("optional")) |optional| { diff --git a/src/install/install.zig b/src/install/install.zig index bcf33cb53..1e55d7807 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -4332,7 +4332,6 @@ pub const PackageManager = struct { bin_path: stringZ = "node_modules/.bin", lockfile_path: stringZ = Lockfile.default_filename, - save_lockfile_path: stringZ = Lockfile.default_filename, did_override_default_scope: bool = false, scope: Npm.Registry.Scope = undefined, @@ -4481,8 +4480,6 @@ pub const PackageManager = struct { cli_: ?CommandLineArguments, bun_install_: ?*Api.BunInstall, ) !void { - this.save_lockfile_path = this.lockfile_path; - var base = Api.NpmRegistry{ .url = "", .username = "", @@ -4570,19 +4567,6 @@ pub const PackageManager = struct { this.local_package_features.optional_dependencies = save; } - if (bun_install.lockfile_path) |save| { - if (save.len > 0) { - this.lockfile_path = try allocator.dupeZ(u8, save); - this.save_lockfile_path = this.lockfile_path; - } - } - - if (bun_install.save_lockfile_path) |save| { - if (save.len > 0) { - this.save_lockfile_path = try allocator.dupeZ(u8, save); - } - } - this.explicit_global_directory = bun_install.global_dir orelse this.explicit_global_directory; } @@ -4663,14 +4647,6 @@ pub const PackageManager = struct { if (cli.token.len > 0) { this.scope.token = cli.token; } - - if (cli.lockfile.len > 0) { - this.lockfile_path = try allocator.dupeZ(u8, cli.lockfile); - } - } - - if (env.map.get("BUN_CONFIG_LOCKFILE_SAVE_PATH")) |save_lockfile_path| { - this.save_lockfile_path = try allocator.dupeZ(u8, save_lockfile_path); } if (env.map.get("BUN_CONFIG_YARN_LOCKFILE") != null) { @@ -5765,7 +5741,6 @@ pub const PackageManager = struct { clap.parseParam("--no-save Don't save a lockfile") catch unreachable, clap.parseParam("--save Save to package.json") catch unreachable, clap.parseParam("--dry-run Don't install anything") catch unreachable, - clap.parseParam("--lockfile Store & load a lockfile at a specific filepath") catch unreachable, clap.parseParam("--frozen-lockfile Disallow changes to lockfile") catch unreachable, clap.parseParam("-f, --force Always request the latest versions from the registry & reinstall all dependencies") catch unreachable, clap.parseParam("--cache-dir Store & load cached data from a specific directory path") catch unreachable, @@ -5955,10 +5930,6 @@ pub const PackageManager = struct { // } // } - if (args.option("--lockfile")) |lockfile| { - cli.lockfile = lockfile; - } - if (args.option("--cwd")) |cwd_| { var buf: [bun.MAX_PATH_BYTES]u8 = undefined; var buf2: [bun.MAX_PATH_BYTES]u8 = undefined; @@ -7756,7 +7727,7 @@ pub const PackageManager = struct { save: { if (manager.lockfile.isEmpty()) { if (!manager.options.dry_run) { - std.fs.cwd().deleteFileZ(manager.options.save_lockfile_path) catch |err| brk: { + std.fs.cwd().deleteFileZ(manager.options.lockfile_path) catch |err| brk: { // we don't care if (err == error.FileNotFound) { if (had_any_diffs) break :save; @@ -7784,7 +7755,7 @@ pub const PackageManager = struct { manager.progress.refresh(); } - manager.lockfile.saveToDisk(manager.options.save_lockfile_path); + manager.lockfile.saveToDisk(manager.options.lockfile_path); if (comptime log_level.showProgress()) { node.end(); manager.progress.refresh(); -- cgit v1.2.3 From 96a1d5382fa6d91af1a315a6dc2dee449e66d846 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Thu, 14 Sep 2023 14:51:39 -0700 Subject: Improve docs --- docs/cli/install.md | 2 +- docs/cli/test.md | 41 ++++++++++++++++++++++++++++++++++++++--- docs/test/mocks.md | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) (limited to 'docs/cli') diff --git a/docs/cli/install.md b/docs/cli/install.md index beaf6ca47..4aa4e7816 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -43,7 +43,7 @@ Running `bun install` will: - **Run** your project's `{pre|post}install` and `{pre|post}prepare` scripts at the appropriate time. For security reasons Bun _does not execute_ lifecycle scripts of installed dependencies. - **Write** a `bun.lockb` lockfile to the project root. -To install in production mode (i.e. without `devDependencies`): +To install in production mode (i.e. without `devDependencies` or `optionalDependencies`): ```bash $ bun install --production diff --git a/docs/cli/test.md b/docs/cli/test.md index dfe78c45b..d505cd6a8 100644 --- a/docs/cli/test.md +++ b/docs/cli/test.md @@ -1,4 +1,4 @@ -Bun ships with a fast built-in test runner. Tests are executed with the Bun runtime, and support the following features. +Bun ships with a fast, built-in, Jest-compatible test runner. Tests are executed with the Bun runtime, and support the following features. - TypeScript and JSX - Lifecycle hooks @@ -7,6 +7,10 @@ Bun ships with a fast built-in test runner. Tests are executed with the Bun runt - Watch mode with `--watch` - Script pre-loading with `--preload` +{% callout %} +Bun aims for compatibility with Jest, but not everything is implemented. To track compatibility, see [this tracking issue](https://github.com/oven-sh/bun/issues/1825). +{% /callout %} + ## Run tests ```bash @@ -103,7 +107,11 @@ See [Test > Lifecycle](/docs/test/lifecycle) for complete documentation. ## Mocks -Create mocks with the `mock` function. Mocks are automatically reset between tests. +{% callout %} +Module mocking (`jest.mock()`) is not yet supported. Track support for it [here](https://github.com/oven-sh/bun/issues/5394). +{% /callout %} + +Create mock functions with the `mock` function. Mocks are automatically reset between tests. ```ts import { test, expect, mock } from "bun:test"; @@ -117,11 +125,38 @@ test("random", async () => { }); ``` +Alternatively, you can use `jest.fn()`, it behaves identically. + +```ts-diff +- import { test, expect, mock } from "bun:test"; ++ import { test, expect, jest } from "bun:test"; + +- const random = mock(() => Math.random()); ++ const random = jest.fn(() => Math.random()); +``` + See [Test > Mocks](/docs/test/mocks) for complete documentation. ## Snapshot testing -Snapshots are supported by `bun test`. See [Test > Snapshots](/docs/test/snapshots) for complete documentation. +Snapshots are supported by `bun test`. + +```ts +// example usage of toMatchSnapshot +import { test, expect } from "bun:test"; + +test("snapshot", async () => { + expect({ a: 1 }).toMatchSnapshot(); +}); +``` + +To update snapshots, use the `--update-snapshots` flag. + +```sh +$ bun test --update-snapshots +``` + +See [Test > Snapshots](/docs/test/snapshots) for complete documentation. ## UI & DOM testing diff --git a/docs/test/mocks.md b/docs/test/mocks.md index 31b5dab41..645e2a394 100644 --- a/docs/test/mocks.md +++ b/docs/test/mocks.md @@ -12,6 +12,23 @@ test("random", async () => { }); ``` +{% callout %} +Alternatively, you can use the `jest.fn()` function, as in Jest. It behaves identically. + +```ts +import { test, expect, jest } from "bun:test"; +const random = jest.fn(() => Math.random()); + +test("random", async () => { + const val = random(); + expect(val).toBeGreaterThan(0); + expect(random).toHaveBeenCalled(); + expect(random).toHaveBeenCalledTimes(1); +}); +``` + +{% /callout %} + The result of `mock()` is a new function that's been decorated with some additional properties. ```ts @@ -31,6 +48,29 @@ random.mock.results; // ] ``` +The following properties and methods are implemented on mock functions. + +- [x] [mockFn.getMockName()](https://jestjs.io/docs/mock-function-api#mockfngetmockname) +- [x] [mockFn.mock.calls](https://jestjs.io/docs/mock-function-api#mockfnmockcalls) +- [x] [mockFn.mock.results](https://jestjs.io/docs/mock-function-api#mockfnmockresults) +- [x] [mockFn.mock.instances](https://jestjs.io/docs/mock-function-api#mockfnmockinstances) +- [x] [mockFn.mock.contexts](https://jestjs.io/docs/mock-function-api#mockfnmockcontexts) +- [x] [mockFn.mock.lastCall](https://jestjs.io/docs/mock-function-api#mockfnmocklastcall) +- [x] [mockFn.mockClear()](https://jestjs.io/docs/mock-function-api#mockfnmockclear) +- [x] [mockFn.mockReset()](https://jestjs.io/docs/mock-function-api#mockfnmockreset) +- [x] [mockFn.mockRestore()](https://jestjs.io/docs/mock-function-api#mockfnmockrestore) +- [x] [mockFn.mockImplementation(fn)](https://jestjs.io/docs/mock-function-api#mockfnmockimplementationfn) +- [x] [mockFn.mockImplementationOnce(fn)](https://jestjs.io/docs/mock-function-api#mockfnmockimplementationoncefn) +- [x] [mockFn.mockName(name)](https://jestjs.io/docs/mock-function-api#mockfnmocknamename) +- [x] [mockFn.mockReturnThis()](https://jestjs.io/docs/mock-function-api#mockfnmockreturnthis) +- [x] [mockFn.mockReturnValue(value)](https://jestjs.io/docs/mock-function-api#mockfnmockreturnvaluevalue) +- [x] [mockFn.mockReturnValueOnce(value)](https://jestjs.io/docs/mock-function-api#mockfnmockreturnvalueoncevalue) +- [x] [mockFn.mockResolvedValue(value)](https://jestjs.io/docs/mock-function-api#mockfnmockresolvedvaluevalue) +- [x] [mockFn.mockResolvedValueOnce(value)](https://jestjs.io/docs/mock-function-api#mockfnmockresolvedvalueoncevalue) +- [x] [mockFn.mockRejectedValue(value)](https://jestjs.io/docs/mock-function-api#mockfnmockrejectedvaluevalue) +- [x] [mockFn.mockRejectedValueOnce(value)](https://jestjs.io/docs/mock-function-api#mockfnmockrejectedvalueoncevalue) +- [x] [mockFn.withImplementation(fn, callback)](https://jestjs.io/docs/mock-function-api#mockfnwithimplementationfn-callback) + ## `.spyOn()` It's possible to track calls to a function without replacing it with a mock. Use `spyOn()` to create a spy; these spies can be passed to `.toHaveBeenCalled()` and `.toHaveBeenCalledTimes()`. -- cgit v1.2.3 From a31d69bf936d0b32d16eaa5f8c914d95e46f3455 Mon Sep 17 00:00:00 2001 From: DuGlaser Date: Fri, 15 Sep 2023 07:19:37 +0900 Subject: fix(docs): Fix the text that `bun run --bun` is the same as `bun` (#4647) * fix(docs): Fix the text that `bun run --bun` is the same as `bun` * Updates --------- Co-authored-by: Colin McDonnell --- docs/cli/run.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs/cli') diff --git a/docs/cli/run.md b/docs/cli/run.md index 65c4842cc..dcd7edd52 100644 --- a/docs/cli/run.md +++ b/docs/cli/run.md @@ -26,10 +26,11 @@ $ bun run index.ts $ bun run index.tsx ``` -The "naked" `bun` command is equivalent to `bun run`. +Alternatively, you can omit the `run` keyword and use the "naked" command; it behaves identically. ```bash $ bun index.tsx +$ bun index.js ``` ### `--watch` -- cgit v1.2.3 From a983ec713feef13f82a60b981103b3bc94db8085 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Thu, 14 Sep 2023 15:30:14 -0700 Subject: Improve run.md --- docs/cli/run.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'docs/cli') diff --git a/docs/cli/run.md b/docs/cli/run.md index dcd7edd52..6d490e8da 100644 --- a/docs/cli/run.md +++ b/docs/cli/run.md @@ -67,7 +67,7 @@ Your `package.json` can define a number of named `"scripts"` that correspond to } ``` -Use `bun