karma-jsx-preprocessor

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...
module.exports = function(config) {
config.set({
frameworks: ['jsx'],
preprocessors: {
'**/*.jsx': ['jsx']
}
});
};
Define project directory
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.