Skip to content

Commit

Permalink
Issue-6526 - clarify web docs for the use of .only() (oven-sh#8600)
Browse files Browse the repository at this point in the history
* Update writing.md

clarify the use of `.only()`

* Update test.d.ts

Small clarification in JSDoc
  • Loading branch information
jcarpe authored and Hanaasagi committed Feb 3, 2024
1 parent 74b2156 commit d7c38ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion docs/test/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ $ bun test --todo

## `test.only`

To run a particular test or suite of tests use `test.only()` or `describe.only()`. Once declared, running `bun test --only` will only execute tests/suites that have been marked with `.only()`.
To run a particular test or suite of tests use `test.only()` or `describe.only()`. Once declared, running `bun test --only` will only execute tests/suites that have been marked with `.only()`. Running `bun test` without the `--only` option with `test.only()` declared will result in all tests in the given suite being executed _up to_ the test with `.only()`. `describe.only()` functions the same in both execution scenarios.

```ts
import { test, describe } from "bun:test";
Expand All @@ -135,6 +135,12 @@ The following command will only execute tests #2 and #3.
$ bun test --only
```

The following command will only execute tests #1, #2 and #3.

```sh
$ bun test
```

## `test.if`

To run a test conditionally, use `test.if()`. The test will run if the condition is truthy. This is particularly useful for tests that should only run on specific architectures or operating systems.
Expand Down
2 changes: 1 addition & 1 deletion packages/bun-types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ declare module "bun:test" {
options?: number | TestOptions,
): void;
/**
* Skips all other tests, except this test.
* Skips all other tests, except this test when run with the `--only` option.
*
* @param label the label for the test
* @param fn the test function
Expand Down

0 comments on commit d7c38ac

Please sign in to comment.