![](/img/trans.png)
[英]Jest.js and Create-react-app: I get "SyntaxError: Cannot use import statement outside a module" when running test
[英]Get `export {default as MyName} from './some-module';` to work with Jest (create-react-app)
使用以下语法在 JS 中重新导出模块时,我不断收到错误TypeError: Cannot read property 'default' of undefined
:
export {default as MyName} from './some-module';
这适用于 create-react-app 但包含的 Jest 测试无法处理它。 Jest 不使用相同的 babel 预设吗? 有没有办法让它工作?
事实证明,我欺骗自己相信这是语法问题,而实际上是循环导入问题。
它之前没有出现,因为应用程序以与测试不同的顺序导入内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.