Registry / testing / esbuild-jest-cli

esbuild-jest-cli

JSON →
library4.0.4jsnpmunverified

A CLI tool that bundles Jest test projects using esbuild for faster test execution. Current stable version is 4.0.4 (March 2025), with irregular releases. It supports Jest 27-29 and Node.js 14+. Differentiating features: automatic Jest config generation, esbuild plugin support, and optional dependency transformation. It can handle ESM and CJS, and includes metafile generation to produce jest.config.json. The tool is maintained by Wix Incubator and is suitable for projects seeking lightweight, efficient test bundling.

npm install esbuild-jest-cli
INSTALL
IMPORT
SIG · ESBUILD-JEST-CLI
E
esbuild-jest-cli
testingjavascriptv4.0.4
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.

build
import { build } from 'esbuild-jest-cli'
const { build } = require('esbuild-jest-cli')
Package is ESM-first; CJS require may fail depending on Node version and configuration.
default
import esbuildJestCli from 'esbuild-jest-cli'
const esbuildJestCli = require('esbuild-jest-cli')
No default export exists (only named exports). The import will fail.
JestCliOptions
import type { JestCliOptions } from 'esbuild-jest-cli'
import { JestCliOptions } from 'esbuild-jest-cli'
Type import only; not a runtime value.

Shows how to configure and run esbuild-jest-cli using a config file or programmatic API.

// In your project root, create .esbuild-jestrc.js: module.exports = { esbuild: { outdir: '.bundle', sourcemap: true, platform: 'node' }, package: { name: 'my-test-bundle' } }; // Run the CLI: // npx esbuild-jest --testPathPattern=.*.test.js // Programmatic usage: import { build } from 'esbuild-jest-cli'; await build({ esbuild: { outdir: 'dist', sourcemap: true, external: ['chalk'] }, package: { name: 'custom-bundle' } }); console.log('Tests bundled successfully!');
esbuild-jest-cli --version
Debug
Known issues
breakingv4.0.0 switched to optional dependencies and @swc/jest internally; preTransform/postTransform callbacks from v3.x are removed.
fix
Migrate to new transformer mechanism; remove any usage of preTransform/postTransform. See changelog for v3->v4 migration.
affects: >=4.0.0 <5.0.0
breakingv3.0.0 changed the transformer callback signatures (preTransform and postTransform).
fix
Update custom transformers to match the new API. See release notes.
affects: >=3.0.0 <4.0.0
gotchaThe tool forces bundle: true, splitting: true, metafile: true, and sets outbase to cwd. Overriding these can cause breakage.
fix
Do not set bundle, splitting, metafile, or outbase in esbuild config — they are internally overridden.
affects: *
deprecatedSupport for Node.js 14.x is deprecated and may be removed in a future major version.
fix
Upgrade Node.js to >=16.x.
affects: *
gotchaThe package is ESM-only; using require() directly may fail in older Node or CJS projects.
fix
Use dynamic import() or ensure your project is configured for ESM.
affects: >=4.0.0
Errors
Common errors & fixes
Cannot find module 'esbuild-jest-cli'
Package not installed, or missing peer dependency esbuild.
fix
Run 'npm install --save-dev esbuild-jest-cli esbuild' and ensure node_modules is correct.
TypeError: (0 , _esbuildJestCli.build) is not a function
Using CommonJS require() on an ESM-only package.
fix
Change to dynamic import: const { build } = await import('esbuild-jest-cli'); or set type: module in package.json.
Jest encountered an unexpected token. Use babel-jest or ts-jest
esbuild-jest-cli did not transform the file correctly, possibly due to misconfiguration.
fix
Ensure Jest config uses esbuild-jest-cli's transformer or run via CLI with correct testPathPattern.
Error: ESBUILD_BINARY_PATH environment variable is not set
The internal esbuild binary path is missing (rare).
fix
Install esbuild globally or set ESBUILD_BINARY_PATH to the esbuild binary location.
Upgrade
Version history
4.0.4latest on npm
Audit
Dependencies
esbuildrequiredRequired as a peer dependency for bundling tests; must be >=0.17.4 per v4.x.
Agent activity
2 hits · last 30 days
node
2
Resources