I'm happily using node 8.6 with the experimental ES6 modules option (--experimental-modules) turned on. This allows me to perfectly write plain ES2015 code for node without the need of babel.
The problem is when I try to create some tests with jest, it fails complaining about a syntax error: "Unexpected token import".
The .babelrc configuration is the following:
{ "env": { "test": { "presets": [ ["env", { "targets": { "node": "8.6" } }] ] } } } My jest.config.js is as follows:
module.exports = { testMatch: ['/tests/**/*.js', '**/?(*.)test.js'], } The error thrown:
/app/tests/integration/controller/data-provider/Credentials/CredentialsList.action.test.js:2 import { Credentials, AdWordsCredentials } from '../../../../../imports/models/data-provider/Credentials.mjs'; ^^^^^^ SyntaxError: Unexpected token import at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:305:17) at Generator.next (<anonymous>) at Promise (<anonymous>) Relevant packages:
- babel-core@^6.26.0
- jest@^21.2.1
- babel-jest@^21.2.0
- babel-preset-env@^1.6.0
Any help will be appreciated. Thanks :)
UPDATE: I've tried calling jest without babel, with the following command, without any change: node --experimental-modules node_modules/.bin/jest