项目作者: marvinhagemeister

项目描述 :
Preprocessor based on esbuild for the karma test runner
高级语言: TypeScript
项目地址: git://github.com/marvinhagemeister/karma-esbuild.git
创建时间: 2021-01-02T20:41:39Z
项目社区:https://github.com/marvinhagemeister/karma-esbuild

开源协议:MIT License

下载


karma-esbuild

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

Installation

  1. npm install --save-dev karma-esbuild

Usage

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

  1. module.exports = function (config) {
  2. config.set({
  3. preprocessors: {
  4. // Add esbuild to your preprocessors
  5. "test/**/*.test.js": ["esbuild"],
  6. },
  7. });
  8. };

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.

  1. module.exports = function (config) {
  2. config.set({
  3. preprocessors: {
  4. // Add esbuild to your preprocessors
  5. "test/**/*.test.js": ["esbuild"],
  6. },
  7. esbuild: {
  8. // Replace some global variables
  9. define: {
  10. COVERAGE: coverage,
  11. "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || ""),
  12. ENABLE_PERFORMANCE: true,
  13. },
  14. plugins: [createEsbuildPlugin()],
  15. // Karma-esbuild specific options
  16. singleBundle: true, // Merge all test files into one bundle(default: true)
  17. },
  18. });
  19. };

License

MIT, see the LICENSE file.