Back To Blog Posts
Configuring es6 with jest
If you are interested in using jest with es6 syntax, you pay run into issues with the spread operator:
As you can see, jest doesnt seem to like ES6’s awesome spread operator ...data
.
After an hour or so, I found the solution. First install stage-2
npm install --save-dev babel-preset-stage-2
Finally update your .babelrc
{
"presets": ["es2015", "react", "stage-2"]
}
Your tests should pass now.
$ jest SubmissionActions-tests.js
Using Jest CLI v0.10.2, jasmine2, babel-jest
Running 1 test suite...{ type: 'CLOSE_TABLE_CELL_EDIT_MODAL' }
PASS actions/__tests__/SubmissionActions-tests.js (0.489s)
1 test passed (1 total in 1 test suite, run time 1.334s)