是否可以在不使用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 模块也可以在本地使用吗?
我使用的Goland(同webstorm /的IntelliJ等),IDE和调试配置存在时,你可以配置一个地方working directory现在我试着将工作与VSCODE,我不觉得这配置,有点研究后,我发现下面的JSON的应处置这,但找不到工作目录的正确位置
例如这是我的工作目录
/Users/i022226/go/src/myapp
"configurations": [{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}"
},
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}"
},
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {},
"args": [],
"showLog": true
}
Run Code Online (Sandbox Code Playgroud)
在“ launch.json添加配置”按钮中,当我键入内容时,cwd我没有任何输入,有任何想法吗?
在这篇文章中cwd是在,option但我找不到option
https://github.com/Microsoft/vscode/issues/856