Socket
Socket
Sign inDemoInstall

karma-commonjs-alias

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    karma-commonjs-alias

A Karma plugin. Test CommonJS modules with added alias support


Version published
Weekly downloads
6
decreased by-40%
Maintainers
1
Install size
9.08 kB
Created
Weekly downloads
 

Readme

Source

karma-commonjs-alias (karma-commonjs with module aliasing)

This is a clone of karma-commonjs with additional features

Here is a link to the original repo karma-commonjs . Go there for a full list of features.

Module aliasing

Added the ability to alias modules for testing. This is useful for mocking and specifying environment. It works the same way as file aliasing in grunt-browserify.

Here is an example karma.conf configuration

module.exports = function (config) {
	config.set({
	   ...
	   commonjsPreprocessor: {
	      alias : {
	        './config/dev.js': 'config'
	      }
	   }
	   ...
  });
}

In another file, you can specify the following and it will be resolve to ./config/dev.js

require('config');

NPM Module Support

Just add NPM modules to the files array and they will be available in the tests

module.exports = function (config) {
	config.set({
	   ...
	   files: [
	      **/*.js
	      'promise-polyfill', // NPM module used in JS files
	      'observable-lite' // Another NPM module
	   ]
	   ...
  });
}

Node/NPM Installation

npm install karma-commonjs-alias

Keywords

FAQs

Last updated on 12 Mar 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc