当我按照说明进行操作时,发现 here
并添加指定的导入引用:
导入“@ui5/webcomponents/dist/Button”;
应用程序工作正常并且能够导入按钮。
但是,当我 npm run test
时,出现错误:
语法错误:无法在模块外部使用 import 语句。
知道如何解决这个问题吗?
最佳答案
已提供答案 here .
{
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!(@ui5|lit-html)).*\\.js$"
]
}
}
关于reactjs - 如何在 create-react-app 中导入 ES6 模块而不导致测试失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60028689/