Search code examples
reactjsjestjscreate-react-appes6-modulesui5-webcomponents

How do I import ES6 Module within a create-react-app without causing tests to fail?


When I follow the instructions found here

and add the import reference as they specify:

import "@ui5/webcomponents/dist/Button";

the application works fine and is able to import the button. However, when I npm run test, I get an error:

SyntaxError: Cannot use import statement outside a module.

Any idea how to fix this?


Solution

  • An answer was provided here.

    {
       "jest": {
          "transformIgnorePatterns": [
             "node_modules/(?!(@ui5|lit-html)).*\\.js$"
          ]
       }
    }