Registry / testing / jest-esbuild

jest-esbuild

JSON →
library0.4.0jsnpmunverified

A Jest transformer that uses esbuild to compile TypeScript/JavaScript files during test execution. Current stable version is 0.4.0, released in 2021 with no recent updates (maintenance mode). It provides fast compilation by leveraging esbuild's speed, significantly faster than ts-jest. It requires Jest 27+ and supports ESM/CJS via esbuild's loader. Key differentiator: minimal configuration and speed compared to ts-jest or babel-jest. Not recommended for projects needing type checking, as esbuild strips types without validation.

npm install jest-esbuild
INSTALL
IMPORT
SIG · JEST-ESBUILD
J
jest-esbuild
testingjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jest-esbuild (default)
module.exports = { transform: { '^.+\\.tsx?$': 'jest-esbuild' } }
transform: { '^.+\\.tsx?$': ['jest-esbuild', {}] }
Correct usage in jest config; options object is not required but can be passed as second element in array.
jest-esbuild (with options)
module.exports = { transform: { '^.+\\.tsx?$': ['jest-esbuild', { loaders: { '.js': 'jsx' } }] } }
transform: { '^.+\\.tsx?$': 'jest-esbuild', esbuildOptions: { loaders: { '.js': 'jsx' } } }
Options must be inline in array, not separate field.
createTransformer (named export)
const { createTransformer } = require('jest-esbuild'); module.exports = { transform: { '^.+\\.tsx?$': createTransformer() } };
const createTransformer = require('jest-esbuild');
Export is named; default export is the transformer itself in CJS but named export exists.

Basic setup to transform .ts/.tsx files with jest-esbuild; test file written in TypeScript.

// Install: npm install -D jest-esbuild // jest.config.js module.exports = { transform: { '^.+\\.tsx?$': 'jest-esbuild' } }; // Example test (sum.test.ts) const sum = (a: number, b: number) => a + b; test('adds 1 + 2 to equal 3', () => { expect(sum(1, 2)).toBe(3); });
Debug
Known issues
gotchajest-esbuild does not type-check; it only transforms code. Type errors will be ignored, potentially masking bugs.
fix
Run tsc separately or add type checking step in CI.
affects: >=0.0.0
deprecatedjest-esbuild is no longer actively maintained. Consider alternatives like @swc/jest or esbuild-jest.
fix
Migrate to @swc/jest (recommended) or esbuild-jest.
affects: >=0.0.0
gotchaOptions for esbuild are not well documented; configuration errors can cause silent failures.
fix
Refer to esbuild API docs; use known options like 'loader', 'jsxFactory', 'target'.
affects: >=0.0.0
breakingVersion 0.4.0 changed from default export to named export? (Unconfirmed breaking change anecdotal)
fix
If using createTransformer, verify import path; recommended: use string transformer in config.
affects: >=0.4.0
Errors
Common errors & fixes
TypeError: (0 , _jestEsbuild.createTransformer) is not a function
Incorrect import of named export; using default import for createTransformer.
fix
Use require('jest-esbuild').createTransformer or import { createTransformer } from 'jest-esbuild'.
Error: jest-esbuild: Expected a jest version >= 27
Jest version < 27 is used.
fix
Upgrade Jest to 27 or later.
SyntaxError: Unexpected token <
JSX files not transformed; missing loader configuration.
fix
Add options: { loaders: { '.tsx': 'tsx' } } in transform array.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
jest-esbuild — npm install jest-esbuild · libregistry