bun · Bun Docs
Bun Writing tests
Teaches how to write and structure test files using Bun's built-in test runner, including syntax for test blocks and assertions.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Bun Writing tests
Teaches how to write and structure test files using Bun's built-in test runner, including syntax for test blocks and assertions.
When To Use
Use when you need to implement unit or integration tests using the Bun test runner and its assertion library.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/bun-writing-tests-workflow-guide.md | A guide covering test execution, features, and specialized testing patterns using the Bun test runner. | Questions about a guide covering test execution, features, and specialized testing patterns using the Bun test runner. |
examples/bun-writing-tests-bun-test-writing-examples.text | Code examples demonstrating how to use the expect and test functions from the bun:test module. | Exact payloads, commands, or snippets shown in Code examples demonstrating how to use the expect and test functions from the bun:test module. |
examples/bun-writing-tests-bun-test-writing-describe-expect.text | A code example demonstrating the use of describe, test, and expect functions within the Bun test runner. | Exact payloads, commands, or snippets shown in A code example demonstrating the use of describe, test, and expect functions within the Bun test runner. |
examples/bun-writing-tests-bun-test-writing.text | A code example demonstrating how to use the expect and test functions from the bun:test module to perform asynchronous assertions. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the expect and test functions from the bun:test module to perform asynchronou... |
examples/bun-writing-tests-bun-test-writing-async-done-callback.text | An example demonstrating how to use the done callback for testing asynchronous code in Bun. | Exact payloads, commands, or snippets shown in An example demonstrating how to use the done callback for testing asynchronous code in Bun. |
examples/bun-writing-tests-bun-test-timeout-assertion.text | A code example demonstrating how to use the timeout option in a Bun test assertion to ensure an asynchronous operation completes within a specified duration. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the timeout option in a Bun test assertion to ensure an asynchronous operatio... |
examples/bun-writing-tests-bun-test-writing-retry-logic.text | A text example demonstrating how to use the retry option within a Bun test assertion to handle flaky network requests. | Exact payloads, commands, or snippets shown in A text example demonstrating how to use the retry option within a Bun test assertion to handle flaky network requests. |
examples/bun-writing-tests-bun-test-repeats-option.text | A code example demonstrating how to use the repeats option within a Bun test to execute a test case multiple times. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the repeats option within a Bun test to execute a test case multiple times. |
examples/bun-writing-tests-bun-test-writing-expect-skip.text | A code example demonstrating how to use the expect and test functions along with test.skip in the Bun test runner. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the expect and test functions along with test.skip in the Bun test runner. |
examples/bun-writing-tests-bun-test-writing-todo.text | A text example demonstrating the use of the test.todo function within the Bun testing framework. | Exact payloads, commands, or snippets shown in A text example demonstrating the use of the test.todo function within the Bun testing framework. |
examples/bun-writing-tests-bun-test-writing-todo-flag.text | An example demonstrating the use of the --todo flag when running tests with the Bun test runner. | Exact payloads, commands, or snippets shown in An example demonstrating the use of the --todo flag when running tests with the Bun test runner. |
examples/bun-writing-tests-bun-test-writing-todo-2.text | A text file demonstrating how to use the .todo method in Bun tests to mark unimplemented features. | Exact payloads, commands, or snippets shown in A text file demonstrating how to use the .todo method in Bun tests to mark unimplemented features. |
examples/bun-writing-tests-bun-test-writing-test-only-describe-only.text | A text example demonstrating the usage of test.only and describe.only within the Bun test runner. | Exact payloads, commands, or snippets shown in A text example demonstrating the usage of test.only and describe.only within the Bun test runner. |
examples/bun-writing-tests-bun-test-only-command-usage.text | A text snippet demonstrating how to use the bun test --only flag to run specific tests. | Exact payloads, commands, or snippets shown in A text snippet demonstrating how to use the bun test --only flag to run specific tests. |
examples/bun-writing-tests-bun-test-writing-examples-2.text | A collection of text-based examples demonstrating how to write and structure tests using the bun test runner. | Exact payloads, commands, or snippets shown in A collection of text-based examples demonstrating how to write and structure tests using the bun test runner. |
examples/bun-writing-tests-bun-test-if-conditional-execution.text | A text example demonstrating the use of the test.if conditional function to execute tests based on runtime conditions. | Exact payloads, commands, or snippets shown in A text example demonstrating the use of the test.if conditional function to execute tests based on runtime conditions. |
examples/bun-writing-tests-bun-test-skipif-platform.text | A code example demonstrating how to use the test.skipIf method to conditionally skip tests based on the operating system platform. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the test.skipIf method to conditionally skip tests based on the operating sys... |
examples/bun-writing-tests-bun-test-todo-if-conditional.text | A code example demonstrating the use of the test.todoIf conditional method in Bun's testing framework. | Exact payloads, commands, or snippets shown in A code example demonstrating the use of the test.todoIf conditional method in Bun's testing framework. |
examples/bun-writing-tests-bun-test-failing-assertion.text | A code example demonstrating how to use the test.failing function in Bun to assert that specific tests are expected to fail. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the test.failing function in Bun to assert that specific tests are expected t... |
examples/bun-writing-tests-bun-test-describe-if-skip-if-examples.text | Code examples demonstrating the use of describe.if and describe.skipIf for conditional test suite execution in Bun. | Exact payloads, commands, or snippets shown in Code examples demonstrating the use of describe.if and describe.skipIf for conditional test suite execution in Bun. |
examples/bun-writing-tests-bun-test-each-parameterized-cases.text | A code example demonstrating how to use the test.each method to run parameterized test cases in Bun. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the test.each method to run parameterized test cases in Bun. |
examples/bun-writing-tests-bun-test-describe-each.text | A code example demonstrating how to use the describe.each method to run parameterized tests in Bun. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the describe.each method to run parameterized tests in Bun. |
examples/bun-writing-tests-bun-test-each-array-and-object-examples.text | Examples demonstrating how to use test.each with arrays and objects in Bun's testing framework. | Exact payloads, commands, or snippets shown in Examples demonstrating how to use test.each with arrays and objects in Bun's testing framework. |
examples/bun-writing-tests-bun-test-each-parameterized-specifiers.text | An example demonstrating how to use test.each with various format specifiers like %s, %i, and %p in Bun tests. | Exact payloads, commands, or snippets shown in An example demonstrating how to use test.each with various format specifiers like %s, %i, and %p in Bun tests. |
examples/bun-writing-tests-bun-test-async-assertions.text | An example demonstrating how to use async functions and expect.hasAssertions() within a Bun test block. | Exact payloads, commands, or snippets shown in An example demonstrating how to use async functions and expect.hasAssertions() within a Bun test block. |
examples/bun-writing-tests-bun-test-expect-assertions.text | A Bun test example demonstrating the use of expect.assertions to verify the exact number of assertions called within a test block. | Exact payloads, commands, or snippets shown in A Bun test example demonstrating the use of expect.assertions to verify the exact number of assertions called within... |
examples/bun-writing-tests-bun-test-expecttypeof-assertions.text | Examples demonstrating the use of expectTypeOf for type assertions and object matching in Bun tests. | Exact payloads, commands, or snippets shown in Examples demonstrating the use of expectTypeOf for type assertions and object matching in Bun tests. |
examples/bun-writing-tests-bun-test-writing-best-practices.text | A text file demonstrating recommended and discouraged patterns for writing test descriptions in Bun. | Exact payloads, commands, or snippets shown in A text file demonstrating recommended and discouraged patterns for writing test descriptions in Bun. |
examples/bun-writing-tests-bun-test-describe-test-syntax.text | A text example demonstrating the use of describe and test blocks for organizing test suites in Bun. | Exact payloads, commands, or snippets shown in A text example demonstrating the use of describe and test blocks for organizing test suites in Bun. |
examples/bun-writing-tests-bun-test-matcher-best-practices.text | A comparison of using specific matchers versus generic equality checks in Bun test suites. | Exact payloads, commands, or snippets shown in A comparison of using specific matchers versus generic equality checks in Bun test suites. |
examples/bun-writing-tests-bun-test-writing-error-handling-examples.text | Examples demonstrating how to test for synchronous and asynchronous error throwing using the Bun test runner. | Exact payloads, commands, or snippets shown in Examples demonstrating how to test for synchronous and asynchronous error throwing using the Bun test runner. |
examples/bun-writing-tests-bun-test-beforeeach-aftereach.text | A text example demonstrating the use of beforeEach and afterEach hooks within the bun:test framework. | Exact payloads, commands, or snippets shown in A text example demonstrating the use of beforeEach and afterEach hooks within the bun:test framework. |
What This Skill Covers
-
- Writing tests - Bun Skip to main content Bun home page Search... ⌘ K Install Bun Search... Navigation Getting Started Writing tests RuntimePackage ManagerB...
- Main sections:
Getting Started,Test Execution,Test Features,Specialized Testing,Reporting.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://bun.sh/docs/test/writing