2

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?

2
  • 1
    Do you use react-scripts test command? Unlike pure jest, react-scripts add some configuration on top, which makes imports working Commented Feb 2, 2020 at 21:59
  • yes, my package.json has "test": "react-scripts test jest-environment-happy-dom", Commented Feb 2, 2020 at 22:46

2 Answers 2

1

An answer was provided here.

{
   "jest": {
      "transformIgnorePatterns": [
         "node_modules/(?!(@ui5|lit-html)).*\\.js$"
      ]
   }
}
Sign up to request clarification or add additional context in comments.

Comments

1

Change it to: "test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!@codemirror)/\"",

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.