From d7c38ac22e813dd9a6e281f8f5e1be03279d2b5b Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 31 Jan 2024 17:12:26 -0500 Subject: [PATCH] Issue-6526 - clarify web docs for the use of `.only()` (#8600) * Update writing.md clarify the use of `.only()` * Update test.d.ts Small clarification in JSDoc --- docs/test/writing.md | 8 +++++++- packages/bun-types/test.d.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/test/writing.md b/docs/test/writing.md index dd9f19179dd8dc..e073ced7342e15 100644 --- a/docs/test/writing.md +++ b/docs/test/writing.md @@ -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"; @@ -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. diff --git a/packages/bun-types/test.d.ts b/packages/bun-types/test.d.ts index 50b3e03b396bc7..43c84e50eea212 100644 --- a/packages/bun-types/test.d.ts +++ b/packages/bun-types/test.d.ts @@ -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