I'm using the code splitting feature of webpack, but it seems that jest doesn't recognize the import() function:
        import('myModule').then(function (myModule) {
        ^^^^^^
SyntaxError: Unexpected token import
I don't have any special setup. My npm test script is simply run jest "test": "jest"
How can I make it work?
I'm using the latest version of jest 20.0.4 and babel-jest 20.0.3
Oh I just found the answer.
Simply install this plugin: https://github.com/airbnb/babel-plugin-dynamic-import-node and add it to the .babelrc file:
{
  ...
  "env": {
    "test": {
      "plugins": ["dynamic-import-node"]
    }
  }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With