karma-string-replace-preprocessor

1.0.4 • Public • Published

karma-string-replace-preprocessor

A preprocessor for Karma that does string replacement on module content on the fly.

Installation

The easiest way is to keep karma-string-replace-preprocessor as a devDependency. You can simple do it by:

npm install karma-string-replace-preprocessor --save-dev

Configuration

Following code shows the default configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
 
    preprocessors: {
      'src/**/*.js': [ 'stringreplace' ]
    },
 
    stringReplacePreprocessor: {
        patterns: [
            { match: 'stringToReplaceOne', replacement: 'This string has been replace with number one.' },
            { match: 'stringToReplaceTwo', replacement: 'This string has been replace with number two.' }
        ]
    },
 
    ...
 
  })
}

Karma Plugins

See the Karma Documentation for additional details on custom - in this case, preprocessor - plugin development.

Dependency Injection in Karma

Dependency Injection in Karma is handled by Node-DI, but that library is deprecated. See the author's readme notes in the repo. Just something to be aware of as this dependency may change in Karma in the future. And, it defines $inject, which is something on which this plugin relies.

Logger

Logger is another dependency of Karma. See log4js


License Info

MIT License

Package Sidebar

Install

npm i karma-string-replace-preprocessor

Weekly Downloads

1

Version

1.0.4

License

none

Unpacked Size

4 kB

Total Files

4

Last publish

Collaborators

  • coldfusioncocoa