karma-react-preprocessor

0.0.4 • Public • Published

karma-react-preprocessor

Build Status

Preprocessor for react jsx files

Installation

The easiest way is to keep karma-react-preprocessor as a devDependency in your package.json.

{
  "devDependencies": {
    "karma": "~0.10",
    "karma-react-preprocessor": "~0.1"
  }
}

You can simple do it by:

npm install karma-react-preprocessor --save-dev

Configuration

Following code shows the default configuration...

// karma.conf.js
module.exports = function(config) {
  config.set({
    preprocessors: {
      '**/*.jsx': ['react']
    }
  });
};

By default preprocessor transform extension from jsx to js. You can change it by:

// karma.conf.js
module.exports = function(config) {
  config.set({
    preprocessors: {
      '**/*.jsx': ['react']
    },
    reactPreprocessor: {
        transformPath: function(path) {
            return path.replace(/\.jsx$/, '.js');
        }
    }
  });
};

You can pass an options object that will be passed to react-tools module. See available options.

// karma.conf.js
module.exports = function(config) {
  config.set({
    preprocessors: {
      '**/*.jsx': ['react']
    },
    reactPreprocessor: {
        harmony: true,
        es6module: true
    }
  });
};

You can look at karma.conf.js how example

For more information on Karma see the homepage.

Package Sidebar

Install

npm i karma-react-preprocessor

Weekly Downloads

54

Version

0.0.4

License

MIT

Last publish

Collaborators

  • maksimr