esbuild-jest-fixed
raw JSON → 0.5.2 verified Fri May 01 auth: no javascript
A Jest transformer leveraging esbuild for fast TypeScript, JavaScript, TSX, and JSX compilation. Version 0.5.2 is the latest stable release; the project is a fork of esbuild-jest that resolves a critical bug where source code containing the substring "ock(" (e.g., "mock(") would cause compilation failures. It supports configurable jsxFactory, jsxFragment, sourcemap, loaders, target, and format options, and is designed as a drop-in replacement for ts-jest with significantly faster transpilation. Requires esbuild >=0.9.3 as a peer dependency. The package ships TypeScript type definitions.
Common errors
error Cannot find module 'esbuild-jest' from 'jest.config.js' ↓
cause Using 'esbuild-jest' in Jest config but package not installed or intended to use fork
fix
Install esbuild-jest-fixed and use 'esbuild-jest-fixed' in config
error TypeError: createTransformer is not a function ↓
cause Importing named export `createTransformer` instead of default import
fix
Use
import createTransformer from 'esbuild-jest-fixed' (no braces) error Module build failed: Error: The package "esbuild" is required but not installed ↓
cause Missing peer dependency esbuild
fix
Run
npm install esbuild --save-dev Warnings
breaking Jest transform keys using 'esbuild-jest' will not work with the fixed fork; must use 'esbuild-jest-fixed' ↓
fix Replace 'esbuild-jest' with 'esbuild-jest-fixed' in Jest configuration transform patterns
gotcha Source code containing substring 'ock(' (e.g., 'mock(' or 'block(') could cause compilation errors in original esbuild-jest <0.2.0; fixed fork resolves this ↓
fix Use esbuild-jest-fixed v0.5.2+ which patches the 'ock(' issue
deprecated The original esbuild-jest package is no longer maintained; this fork is the active alternative ↓
fix Migrate to esbuild-jest-fixed for continued support and bug fixes
Install
npm install esbuild-jest-fixed yarn add esbuild-jest-fixed pnpm add esbuild-jest-fixed Imports
- esbuild-jest-fixed wrong
import { createTransformer } from 'esbuild-jest-fixed'correctimport createTransformer from 'esbuild-jest-fixed' - Options (type) wrong
import { Options } from 'esbuild-jest-fixed' // Options is a type, not a runtime valuecorrectimport type { Options } from 'esbuild-jest-fixed' - Jest config string reference wrong
"esbuild-jest" in config when using the forkcorrect"esbuild-jest-fixed" in Jest transform config
Quickstart
// jest.config.js
module.exports = {
transform: {
'^.+\\.tsx?$': [
'esbuild-jest-fixed',
{
sourcemap: true,
target: 'es2020'
}
]
}
};
// example.test.ts
import { sum } from './sum';
test('sum adds numbers', () => {
expect(sum(1, 2)).toBe(3);
});
// sum.ts
export function sum(a: number, b: number): number {
return a + b;
}
// Run: npx jest