next.js: with-jest example doesnt work
when i run test from npm scripts i have error
C:\with-jest-app\jest.setup.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { configure } from 'enzyme';
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
| Tech | Version |
|---|---|
| next | 5.1.0 |
| node | 10.0.0 |
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 28 (8 by maintainers)
Commits related to this issue
- Fix with-jest example Fixes #4263 — committed to timneutkens/next.js by timneutkens 9 years ago
- Fix with-jest example (#4278) Fixes #4263 — committed to vercel/next.js by timneutkens 9 years ago
- Fix with-jest example (#4278) Fixes #4263 — committed to lependu/next.js by timneutkens 9 years ago
Hello there! I added this following
.babelrcand installed
yarn add --dev babel-jest babel-preset-env babel-preset-reactWorked for me.
and now seeing this error
@binarykitchen I also got that error and fixed it by adding
"babel-core": "7.0.0-bridge.0"to package.json as shown here: https://github.com/zeit/next.js/blob/905da6f92bd36b48c5067f1f1525004777213e17/examples/with-jest/package.json#L5how would we enable babel to use es6 instead of es5?
@binarykitchen you’re not using the example 🤔 https://github.com/zeit/next.js/blob/canary/examples/with-jest/.babelrc https://github.com/zeit/next.js/blob/canary/examples/with-jest/package.json#L5-L6