Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karma-webpack

Package Overview
Dependencies
Maintainers
6
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-webpack

Use webpack with karma

  • 5.0.0-alpha.6
  • next
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
358K
decreased by-11.87%
Maintainers
6
Weekly downloads
 
Created

What is karma-webpack?

karma-webpack is a plugin that allows you to use Webpack to preprocess files in Karma. It enables you to bundle your test files using Webpack, which is particularly useful for projects that already use Webpack for their build process. This integration helps in leveraging Webpack's features like module bundling, code splitting, and asset management in your test environment.

What are karma-webpack's main functionalities?

Preprocessing Files

This feature allows you to preprocess your test files using Webpack. By specifying the files and preprocessors in the Karma configuration, you can bundle your test files with Webpack before running them in the browser.

module.exports = function(config) {
  config.set({
    frameworks: ['mocha'],
    files: [
      'test/**/*.spec.js'
    ],
    preprocessors: {
      'test/**/*.spec.js': ['webpack']
    },
    webpack: {
      // Webpack configuration
    },
    browsers: ['Chrome'],
    singleRun: true
  });
};

Using Webpack Loaders

This feature allows you to use Webpack loaders in your test environment. For example, you can use Babel to transpile your ES6 code to ES5 before running your tests.

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    files: [
      'test/**/*.spec.js'
    ],
    preprocessors: {
      'test/**/*.spec.js': ['webpack']
    },
    webpack: {
      module: {
        rules: [
          {
            test: /\.js$/,
            exclude: /node_modules/,
            use: 'babel-loader'
          }
        ]
      }
    },
    browsers: ['Firefox'],
    singleRun: true
  });
};

Source Maps

This feature allows you to generate source maps for your test files. Source maps help in debugging by mapping the transpiled code back to the original source code.

module.exports = function(config) {
  config.set({
    frameworks: ['mocha'],
    files: [
      'test/**/*.spec.js'
    ],
    preprocessors: {
      'test/**/*.spec.js': ['webpack']
    },
    webpack: {
      devtool: 'inline-source-map'
    },
    browsers: ['Chrome'],
    singleRun: true
  });
};

Other packages similar to karma-webpack

Keywords

FAQs

Package last updated on 30 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc