I use webpack to develop a React component. Here is a simple version of it:
\'use strict\';
require(\'./MyComponent.less\');
var React = require(\'react\')
I think a less hacky solution would be to wrap your preprocessor in a conditional on the filename matching a javascript file:
if (filename.match(/\.jsx?$/)) {
return babelJest.process(src, filename);
} else {
return '';
}
This works even if you don't explicitly set the extension in the require line and doesn't require a regex substitution on the source.