How can I use Jest to test React components written in CoffeeScript + React jsx?
The only CoffeeScript example provided with Jest uses plain CoffeeScript, and doesn\
I have just published a boiler plate unit test for Jest that works with React & CoffeeScript.
https://github.com/Cotidia/jest-react-coffeescript
The preprocessor needs to be as follows:
var coffee = require('coffee-script');
var ReactTools = require('react-tools');
module.exports = {
process: function(src, path) {
// console.log('src', src);
if (path.match(/\.coffee$/)) {
// First we compile the coffeescript files to JSX
compiled_to_js = coffee.compile(src, {bare: true});
// Then we compile the JSX to React
compiled_to_react = ReactTools.transform(compiled_to_js)
return compiled_to_react;
}
return src;
}
};