karma-esbuild

2.3.0 • Public • Published

karma-esbuild

An esbuild preprocessor for the karma test runner. The main benefits of esbuild is speed and readability of the compiled output.

Installation

npm install --save-dev karma-esbuild

Usage

Add esbuild as your preprocessor inside your karma.conf.js:

module.exports = function (config) {
	config.set({
		preprocessors: {
			// Add esbuild to your preprocessors
			"test/**/*.test.js": ["esbuild"],
		},
	});
};

Advanced: Custom configuration

A custom esbuild configuration can be passed via an additional property on karma's config. Check out the documentation for esbuild for available options.

module.exports = function (config) {
	config.set({
		preprocessors: {
			// Add esbuild to your preprocessors
			"test/**/*.test.js": ["esbuild"],
		},

		esbuild: {
			// Replace some global variables
			define: {
				COVERAGE: coverage,
				"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || ""),
				ENABLE_PERFORMANCE: true,
			},
			plugins: [createEsbuildPlugin()],

			// Karma-esbuild specific options
			singleBundle: true, // Merge all test files into one bundle(default: true)
		},
	});
};

License

MIT, see the LICENSE file.

Package Sidebar

Install

npm i karma-esbuild

Weekly Downloads

3,840

Version

2.3.0

License

MIT

Unpacked Size

29.6 kB

Total Files

9

Last publish

Collaborators

  • jridgewell
  • marvinhagemeister