-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traceur not working with Jest. Unable to use ES6. #97
Comments
Any luck on this? |
package.json "jest": {
"setupEnvScriptFile": "<rootDir>/node_modules/traceur/bin/traceur-runtime.js",
} preprocessor.js var traceur = require('traceur');
module.exports = {
process: function(src, path) {
if (path.indexOf('node_modules') === -1) {
src = traceur.compile(src);
}
return src;
}
}; You can try add above code to test. |
No luck doing the same. When I try to run the traceur compiler in a preprocess function, I get the following error:
|
I'm trying to combine React + ES6 with Jest, and can't get beyond the following:
When I try to run the tests, I get the following error:
The module I'm trying to test exports an ES6 class (it has no imports). The test just tries to create an instance of the class and verify a property on it. No matter how I wire it, when I get Traceur involved, I hit this error. |
Hey guys, contributor to 6to5 here. I'm not sure how to get traceur working, but 6to5 has an official jest plugin to make it easier. It also plays well with react/jsx if you're using those. If you need any help let me know or feel free to stop by our gitter room. |
If you are working with React, react-tools supports ES6 transform.
|
@randylien You can get much more ES6 support in addition to full React/JSX support in 6to5. http://6to5.org/docs/usage/jsx/ |
It may be failing if you're not also including the Traceur runtime. Your transform should also concat the traceur runtime to the top of the file. I have no idea where the error about defining |
Looks like this is how you can use ES6 with React package.son
preprocessor.js
It's basically the same procedure shown here http://facebook.github.io/jest/docs/tutorial-react.html#content with the addition of the |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
My codebase is written in ES6 so I tried to set-up Traceur as scriptPreprocessor
Package.json
preprocessor.js
When I try to run my tests with
npm test
I always get:The text was updated successfully, but these errors were encountered: