bun-jest-migration

Solid

Use when migrating from Jest to Bun's test runner, import compatibility, mocks, and config.

Testing & QA 159 stars 25 forks Updated 2 weeks ago MIT

Install

View on GitHub

Quality Score: 88/100

Stars 20%
73
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Bun Jest Migration Bun's test runner is Jest-compatible. Most Jest tests run without changes. ## Quick Migration ```bash # 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 ```typescript // 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 | Jest | Bun Equivalent | |------|----------------| | `jest.mock('module')` | `mock.module('module', () => {...})` | | `jest.useFakeTimers()` | `import { setSystemTime } from "bun:test"` | | `jest.setTimeout()` | Third argument to `test()` | | `jest.clearAllMocks()` | Call `.mockClear()` on each mock | ## Mock Migration ### Mock Functions ```typescript // Jest const fn = jest.fn().mockReturnValue('value'); // Bun const fn = mock(() => 'value'); // Or for compatibility: import { jest } from "bun:test"; const fn = jest.fn(() => 'value'...

Details

Author
secondsky
Repository
secondsky/claude-skills
Created
6 months ago
Last Updated
2 weeks ago
Language
TypeScript
License
MIT

Integrates with

Related Skills