'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 1:[1]
An answer was provided here.
{
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!(@ui5|lit-html)).*\\.js$"
]
}
}
Solution 2:[2]
Change it to: "test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!@codemirror)/\"",
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Bruce |
Solution 2 |