Registry / testing / karma-esbuild-next

karma-esbuild-next

JSON →
library1.1.0jsnpmunverified

An esbuild preprocessor for the Karma test runner, forked from karma-esbuild. It leverages esbuild for fast compilation and readable output, supporting custom esbuild configurations, plugin integration, and single-bundle mode to merge test files into one bundle. Current version 1.1.0 requires esbuild >=0.17.0. Compared to alternatives like karma-webpack or karma-rollup, it offers significantly faster build times due to esbuild's speed, while maintaining compatibility with Karma's standard preprocessor interface.

npm install karma-esbuild-next
INSTALL
IMPORT
SIG · KARMA-ESBUILD-NEXT
K
karma-esbuild-next
testingjavascriptv1.1.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.

karma-esbuild-next
npm install --save-dev karma-esbuild-next
npm install --save-dev karma-esbuild
Install the package, then configure in karma.conf.js
config.set({ preprocessors: { "test/**/*.test.js": ["esbuild"] } })
preprocessors: { "test/**/*.test.js": ["esbuild"] }
preprocessors: { "test/**/*.test.js": ["karma-esbuild-next"] }
The preprocessor name is 'esbuild', not the package name
esbuild config block
config.set({ esbuild: { define: {}, plugins: [], singleBundle: true } })
config.set({ esbuild: { bundle: true } })
Use 'singleBundle' for bundling test files; 'bundle' is an esbuild option but not directly supported

Configure Karma to use esbuild preprocessor with Mocha, a define variable, and single bundle mode.

// karma.conf.js module.exports = function (config) { config.set({ frameworks: ['mocha'], files: ['test/**/*.test.js'], preprocessors: { 'test/**/*.test.js': ['esbuild'] }, plugins: [ 'karma-esbuild-next' ], esbuild: { define: { 'process.env.NODE_ENV': JSON.stringify('test') }, singleBundle: true }, browsers: ['ChromeHeadless'], singleRun: true }); };
Debug
Known issues
gotchaPreprocessor name must be 'esbuild', not the package name
fix
Use 'esbuild' in preprocessors array, not 'karma-esbuild-next'
affects: >=1.0.0
breakingRequires esbuild >=0.17.0; older versions may fail
fix
Update esbuild to version 0.17.0 or later
affects: >=1.0.0
gotchasingleBundle defaults to true; all test files are bundled into one. This can cause issues if tests rely on separate scopes for globals.
fix
Set singleBundle: false if you need separate bundles per test file
affects: >=1.0.0
deprecatedThe original karma-esbuild package is unmaintained; this fork is the recommended alternative
fix
Switch to karma-esbuild-next
affects: >=0.0.0
Errors
Common errors & fixes
Error: No provider for "framework:esbuild"! (Resolving: esbuild)
Missing 'esbuild' in preprocessors array incorrectly, or plugin not installed
fix
Ensure you have added 'karma-esbuild-next' to plugins array in karma.conf.js
Error: Cannot find module 'karma-esbuild-next'
Package not installed or not listed in package.json devDependencies
fix
Run 'npm install --save-dev karma-esbuild-next'
Error: esbuild: Unexpected option: bundle
Using esbuild 'bundle' option inside esbuild config block in karma.conf.js
fix
Use 'singleBundle' instead of 'bundle' for Karma-specific bundling
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency: esbuild is required for compilation
Agent activity
6 hits · last 30 days
node
6
Resources
karma-esbuild-next — npm install karma-esbuild-next · libregistry