Type definitions for Bun's test runner without requiring the full @types/bun
package.
This package re-exports the TypeScript type definitions for bun:test
so that you can use Bun as a test runner without needing to install the complete @types/bun
package as a dependency.
This is particularly useful for:
- Libraries that use Bun only for testing but don't depend on Bun at runtime
- Projects that want to minimize their dependency footprint
- Codebases that need type definitions only for Bun's test runner
Install the package with an alias so TypeScript can find it automatically:
# bun
bun i -d @types/bun-test@npm:@travvy/bun-test
# npm
npm i -D @types/bun-test@npm:@travvy/bun-test
This installs the package @travvy/bun-test
but aliases it as @types/bun-test
so TypeScript automatically picks up the type definitions (packages from @types/*
are special).
Once installed with the proper alias, TypeScript will automatically pick up the type definitions for bun:test
. You can import and use the test runner as normal:
import { test, expect, describe } from "bun:test";
test("my test", () => {
expect(1 + 1).toBe(2);
});
describe("group", () => {
test("nested test", () => {
expect(true).toBeTrue();
});
});
- Smaller dependency footprint: Only includes the types needed for testing
- Focused purpose: When you only need Bun as a test runner
- Cleaner dependency graph: Avoid depending on the full Bun typings when unnecessary
See Bun's LICENSE