https://github.com/marvinhagemeister/karma-esbuild
Preprocessor based on esbuild for the karma test runner
https://github.com/marvinhagemeister/karma-esbuild
esbuild karma karma-plugin karma-preprocessor
Last synced: about 1 month ago
JSON representation
Preprocessor based on esbuild for the karma test runner
- Host: GitHub
- URL: https://github.com/marvinhagemeister/karma-esbuild
- Owner: marvinhagemeister
- License: mit
- Created: 2021-01-02T20:41:39.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-06T17:22:22.000Z (over 1 year ago)
- Last Synced: 2025-04-08T22:01:40.271Z (about 1 month ago)
- Topics: esbuild, karma, karma-plugin, karma-preprocessor
- Language: TypeScript
- Homepage:
- Size: 236 KB
- Stars: 21
- Watchers: 4
- Forks: 10
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# karma-esbuild
An [esbuild](https://github.com/evanw/esbuild) preprocessor for the karma test runner. The main benefits of `esbuild` is speed and readability of the compiled output.
## Installation
```bash
npm install --save-dev karma-esbuild
```## Usage
Add `esbuild` as your preprocessor inside your `karma.conf.js`:
```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](https://esbuild.github.io/api/) for available options.
```js
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](./LICENSE) file.