
Bun Jest Migration
Migrating from Jest to Bun's test runner is mostly painless since Bun maintains Jest compatibility, but there are a few gotchas around module mocking and timers. This guide walks you through removing Jest dependencies, updating imports from @jest/globals to bun:test, and translating the parts that differ (like jest.mock becoming mock.module and jest.fn becoming mock). The configuration section showing jest.config.js to bunfig.toml conversion is helpful, and the troubleshooting table catches the main pain points like mock hoisting not working the same way. If you're moving a test suite to Bun, this covers the practical stuff you'll actually hit.
- skills.sh installs
- 326
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill bun-jest-migration --agent claude-codeInstalls into .claude/skills of the current project.
Files
Bun Jest Migration
Bun's test runner is Jest-compatible. Most Jest tests run without changes.
Quick Migration
# 1. Remove Jest dependencies
bun remove jest ts-jest @types/jest babel-jest
# 2. Update test script
# package.json: "test": "bun test"
# 3. Run tests
bun test
Import Changes
// Before (Jest)
import { describe, it, expect, jest } from '@jest/globals';
// After (Bun) - No import needed, or explicit:
import { describe, test, expect, mock, spyOn } from "bun:test";
API Compatibility
Fully Compatible
| Jest | Bun | Notes |
|---|---|---|
describe() | describe() | Identical |
it() / test() | test() | Use test() |
expect() | expect() | Same matchers |
beforeAll/Each | beforeAll/Each | Identical |
afterAll/Each | afterAll/Each | Identical |
jest.fn() | mock() | Use mock() |
jest.spyOn() | spyOn() | Identical |
Requires Changes
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Category
- Testing & QA
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Bun Websocket Server326
- Cloudflare Workers Runtime Apis326
- Swift Best Practices326
- Bun Nuxt323
- Bun Macros322
- Cloudflare Workers Frameworks321
- Supabase Postgres Best Practices319
- Cloudflare Workers Ci Cd318
- Cloudflare Workers Dev Experience317
- Cloudflare Workers Observability315
- Cloudflare Workers Migration310
- Cloudflare Workers Multi Lang310
- Verification Before Completion310
- Nuxt Studio308
- Neon Vercel Postgres294
- Chrome Devtools288
- Database Sharding277
- Sveltia Cms277
- Google Gemini File Search272
- Tailwind V4 Shadcn8.2K
- Aceternity Ui1.6K
- Vitest Testing1.3K
- Motion1.1K
- Playwright1.1K