bun-test-basics
FeaturedUse for bun:test syntax, assertions, describe/it, test.skip/only/each, and basic patterns.
Testing & QA 221 stars
31 forks Updated today MIT
Install
Quality Score: 91/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Bun Test Basics
Bun ships with a fast, built-in, Jest-compatible test runner. Tests run with the Bun runtime and support TypeScript/JSX natively.
## Quick Start
```bash
# Run all tests
bun test
# Run specific file
bun test ./test/math.test.ts
# Run tests matching pattern
bun test --test-name-pattern "addition"
```
## Writing Tests
```typescript
import { test, expect, describe } from "bun:test";
test("2 + 2", () => {
expect(2 + 2).toBe(4);
});
describe("math", () => {
test("addition", () => {
expect(1 + 1).toBe(2);
});
test("subtraction", () => {
expect(5 - 3).toBe(2);
});
});
```
## Test File Patterns
Bun discovers test files matching:
- `*.test.{js|jsx|ts|tsx}`
- `*_test.{js|jsx|ts|tsx}`
- `*.spec.{js|jsx|ts|tsx}`
- `*_spec.{js|jsx|ts|tsx}`
## Test Modifiers
```typescript
// Skip a test
test.skip("not ready", () => {
// won't run
});
// Only run this test
test.only("focus on this", () => {
// other tests won't run
});
// NOTE: in Bun 1.3+ `bun test` exits non-zero in CI when a file uses
// `test.only`. Use it for local debugging only — never commit it.
// Placeholder for future test
test.todo("implement later");
// Expected to fail
test.failing("known bug", () => {
throw new Error("This is expected");
});
```
## Parameterized Tests
```typescript
test.each([
[1, 1, 2],
[2, 2, 4],
[3, 3, 6],
])("add(%i, %i) = %i", (a, b, expected) => {
expect(a + b).toBe(expected);
});
// With objects
test.each([
{ a: 1, b: 2, expected: 3...
Details
- Author
- secondsky
- Repository
- secondsky/claude-skills
- Created
- 10 months ago
- Last Updated
- today
- Language
- TypeScript
- License
- MIT
Integrates with
Similar Skills
Semantically similar based on skill content — not just same category
Testing & QA Listed
testing-bun
Use when writing or modifying tests in a Bun project
3 Updated today
LandonSchropp Testing & QA Listed
bun
Use when building, testing, and deploying JavaScript/TypeScript applications. Reach for Bun when you need to run scripts, manage dependencies, bundle code, or test applications with a single unified tool.
0 Updated today
samuhlo Testing & QA Listed
bun
Use when building, testing, and deploying JavaScript/TypeScript applications. Reach for Bun when you need to run scripts, manage dependencies, bundle code, or test applications with a single unified tool.
2 Updated 1 weeks ago
FJRG2007