是否可以在不使用esm或不使用 Jest 的情况下使用 Jest 测试 ES6 模块babel?由于node v13本机支持 es6 已经尝试过:
//package.json
{
…
"type": "module"
…
}
//__tests__/a.js
import Foo from '../src/Foo.js';
$ npx jest
Jest encountered an unexpected token
…
Details:
/home/node/xxx/__tests__/a.js:1
import Foo from '../src/Foo.js';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Run Code Online (Sandbox Code Playgroud)
当 babel 添加一个转译器时,它可以工作,但是 es6 模块也可以在本地使用吗?