How can I use Jest to test React components written in CoffeeScript + React jsx?
The only CoffeeScript example provided by Jest uses simple CoffeeScript and does not work with CoffeeScript + React JSX (syntax error when it reaches < ).
What i tried
first try: execSync
// preprocessor.js var execSync = require('exec-sync'); module.exports = { process: function (src, path) { return execSync('browserify -t coffee-reactify ' + path); } };
This works, but takes too much time (good 12 seconds for a dummy test).
Then I tried:
second attempt: coffee-reaction-conversion
// preprocessor.js var coffee = require('coffee-script'); var transform = require('coffee-react-transform'); module.exports = { process: function(src, path) { if (path.match(/\.coffee$/)) { return coffee.compile(transform(src), {'bare': true}); } return src; } };
This causes a strange error, for example:
TypeError: function () {...} does not have a getPooled method
The only Google result for βdoes not have a getPooled methodβ is this meaning , which accurately shows the error I am getting, but does not offer other ideas.
third possible attempt
I think I could use coffee-reactify , but it returns a stream that is asynchronous, and the process function in preprocess.js used synchronously, and has not yet found a way to read the stream synchronously.
What can I do?
giorgian
source share