karma-jsx-preprocessor

0.0.9 • Public • Published

karma-jsx-preprocessor

Build Status Build Status

Preprocessor for server side javascript

Installation

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

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

You can simple do it by:

npm install karma-jsx-preprocessor --save-dev

Configuration

Following code shows the default configuration...

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

Define project directory

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

Now you can include file by path projectDir/<originalFilePath>

Usage

it('should include server module', function() {
    var system = new jsx.System();
    expect(system.include('projectDir/test/server/fixture/foo.jsx')).to.be.equal('Hello World');
});
 
it('should include server module and eval it in special context', function() {
    var system = new jsx.System();
    var barModule = system.include('projectDir/test/server/fixture/bar.jsx', {
        User: {
            name: 'Guest'
        }
    });
 
    expect(barModule()).to.be.equal('Hello Guest');
});

See test/server/unit and karma-test.conf.js


For more information on Karma see the homepage.

Readme

Keywords

none

Package Sidebar

Install

npm i karma-jsx-preprocessor

Weekly Downloads

0

Version

0.0.9

License

MIT

Last publish

Collaborators

  • maksimr