If I use import/export from ES6 then all my Jest tests fail with error:
Unexpected reserved word
I convert my object un
According to this issue, there is native support of ESM from jest@25.4.0. So you won't have to use babel anymore. At the time of writing this answer (05/2020), to activate that you need to do three simple things:
import statements by setting transform: {} in config filenode@^12.16.0 || >=13.2.0 with --experimental-vm-modules flagjest-environment-node or jest-environment-jsdom-sixteen.So your Jest configuration file should contain at least this:
export default {
testEnvironment: 'jest-environment-node',
transform: {}
...
};
And to set --experimental-vm-modules flag, you will have to run Jest as follows:
node --experimental-vm-modules node_modules/jest/bin/jest.js
(I hope this will change in the future)