Skip to content

Instantly share code, notes, and snippets.

@anyong
Created April 27, 2015 03:11
Show Gist options
  • Save anyong/02bc3f512daef6baf808 to your computer and use it in GitHub Desktop.
Save anyong/02bc3f512daef6baf808 to your computer and use it in GitHub Desktop.
var ReactTools = require('react-tools');
var babel = require('babel-jest').process;
module.exports = {
process: function(src, filename) {
if (!filename.match(/\.jsx$/)) {
return '';
}
return ReactTools.transform(babel(src, filename));
}
};
/**
* - TypeError: app\scripts\components\TestComponent.jsx: undefined is not a function
at app\scripts\components\TestComponent.jsx:4:27
at Suite.<anonymous> (app\scripts\components\__tests__\TestComponent-test.jsx:6:23)
at env.describe_ (<anonymous>:40:25)
at env.describe (<anonymous>:27:19)
at describe (node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:604:27)
at app\scripts\components\__tests__\TestComponent-test.jsx:4:1
*/
var babel = require('babel');
module.exports = {
process: function(src, filename) {
// Ignore files other than .js, .es, .jsx or .es6
if (!babel.canCompile(filename)) {
return '';
}
// Ignore all files within node_modules
if (filename.indexOf('node_modules') === -1) {
return babel.transform(src, {filename: filename}).code;
}
return src;
}
};
/**
* Error: Worker process exited before responding! exit code: 3221225477, exit signal: null
stderr:
A worker process has quit unexpectedly! This is bad news, shutting down now!
npm ERR! Test failed. See above for more details.
*/
jest.dontMock('../TestComponent');
describe('test component', function() {
var TestComponent = require('../TestComponent');
});
var React = require('react');
var TestComponent = React.createClass({
render () {
return (
<div>
Hello, test!
</div>
);
}
});
module.exports = TestComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment