bun-jest-migration

Migrates Jest test suites to Bun's test runner with API and config mappings.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-jest-migration-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bun-jest-migration
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/bun-jest-migration
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-jest-migration-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Moving an existing Jest test suite to Bun's test runner involves subtle API differences in mocks, timers, module mocking, and configuration that cause confusing failures if handled ad hoc. ## Core Features & Use Cases - API Compatibility Mapping: Side-by-side tables for describe/test/expect, mocks, spies, timers, and snapshots showing what works unchanged and what needs rewriting. - Config Conversion: Guidance for translating jest.config.js settings (testMatch, timeout, setupFiles, coverage thresholds) into bunfig.toml equivalents. - Troubleshooting Playbook: Fixes for common migration errors such as jest.mock hoisting, missing timer functions, custom matchers, and snapshot mismatches. - Use Case: A team switching a TypeScript project from Jest to Bun runs bun test, hits jest is not defined and module mock failures, then follows the step-by-step migration to update imports, mocks, and scripts. ## Quick Start Ask the assistant to migrate your project's Jest tests to Bun's test runner and update the configuration accordingly.

Frequently Asked Questions about bun-jest-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate from Jest to Bun test runner?

Remove Jest packages with bun remove, change the test script to bun test, convert jest.config.js to bunfig.toml, and update imports from @jest/globals to bun:test. Then run bun test and fix remaining mock or timer errors.

How do I replace jest.mock in Bun?

Bun uses mock.module('module', () => ({...})) instead of jest.mock, and it does not hoist calls like Jest. Place mock.module before imports or use dynamic imports so the mock registers before the module loads.

Is Bun's test runner compatible with Jest APIs?

Most core APIs are identical: describe, test, expect matchers, lifecycle hooks, spyOn, and snapshots. Differences include mock() replacing jest.fn(), mock.module replacing jest.mock, and timeouts passed as a test argument.

Does Bun support Jest fake timers and setSystemTime?

Bun supports Jest-compatible timer APIs including jest.useFakeTimers, jest.setSystemTime, and jest.advanceTimersByTime via the jest export from bun:test. You can also import setSystemTime directly for date mocking.

Why does jest.mock not work after migrating to Bun?

Jest's top-level mock hoisting does not exist in Bun, so mocks registered after imports have no effect. Move mock.module above the import statements or switch to dynamic imports after registering the mock.