Mar*_*son 3 javascript mocha.js reactjs visual-studio-code
我设法打破了我的断点,但我遇到了一些问题.
--compilers jsx:babel-register从.js 添加和重命名为.jsx,断点不再受到攻击.似乎阻止它完全运行的摩卡选项:
--require babel-register
--require test/util/dom.js
--require expect
--compilers jsx:babel-register
Run Code Online (Sandbox Code Playgroud)
Launch.json
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Debug Mocha Test",
"type": "node",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"test/**/*.spec.js", //I need to get this working with .jsx files
"--require", "babel-register"
],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"env": { }
}
]
}
Run Code Online (Sandbox Code Playgroud)
事实证明这是节点调试器的一个错误.我通过更改修复了所有问题:
"type": "node"到"type": "node2".
Launch.json
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Debug Mocha Test",
"type": "node2",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"test/**/*.spec.jsx",
"--colors", "--no-timeouts"
],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"env": { }
}
]
}
Run Code Online (Sandbox Code Playgroud)
mocha.opts:
--require babel-register
--require test/util/dom.js
--require expect
--compilers jsx:babel-register
Run Code Online (Sandbox Code Playgroud)
答案取自weinand.
您还需要在根应用程序中使用.babelrc文件"retainLines": true.这是我的.babelrc文件,例如:
{
"presets": [
"es2015",
"stage-2",
"react"
],
"plugins": [
"transform-es2015-modules-umd"
],
"retainLines": true
}
Run Code Online (Sandbox Code Playgroud)
如果您获得bad option: --inspect=...,请尝试安装较新版本的节点.
| 归档时间: |
|
| 查看次数: |
1307 次 |
| 最近记录: |