admin管理员组文章数量:1294384
I'm using the code splitting feature of webpack, but it seems that jest doesn't recognize the import()
function:
import('myModule').then(function (myModule) {
^^^^^^
SyntaxError: Unexpected token import
I don't have any special setup. My npm test script is simply run jest "test": "jest"
How can I make it work?
I'm using the latest version of jest 20.0.4 and babel-jest 20.0.3
I'm using the code splitting feature of webpack, but it seems that jest doesn't recognize the import()
function:
import('myModule').then(function (myModule) {
^^^^^^
SyntaxError: Unexpected token import
I don't have any special setup. My npm test script is simply run jest "test": "jest"
How can I make it work?
I'm using the latest version of jest 20.0.4 and babel-jest 20.0.3
Share Improve this question asked Jun 20, 2017 at 3:25 CodinCatCodinCat 15.9k6 gold badges50 silver badges63 bronze badges1 Answer
Reset to default 10Oh I just found the answer.
Simply install this plugin: https://github./airbnb/babel-plugin-dynamic-import-node and add it to the .babelrc
file:
{
...
"env": {
"test": {
"plugins": ["dynamic-import-node"]
}
}
}
本文标签: javascriptCode splitting import breaks Jest testsStack Overflow
版权声明:本文标题:javascript - Code splitting `import` breaks Jest tests - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741598536a2387557.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论