[英]VSCode How do I debug with es6 mocha unit tests and jsx files
I manage to hit my breakpoint, but I have a few problems. 我设法打破了我的断点,但我遇到了一些问题。
--compilers jsx:babel-register
and renaming from .js to .jsx and the breakpoint just doesn't get hit any more. --compilers jsx:babel-register
并从.js重命名为.jsx,断点就不再受到攻击了。 Mocha options that seem to stop it working completely: 似乎阻止它完全运行的摩卡选项:
--require babel-register
--require test/util/dom.js
--require expect
--compilers jsx:babel-register
Launch.json 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": { }
}
]
}
Turns out that this is a bug with the node debugger. 事实证明这是节点调试器的一个错误。 I fixed all of the problems by changing:
我通过更改修复了所有问题:
"type": "node"
to "type": "node2"
. "type": "node"
到"type": "node2"
。
Launch.json 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": { }
}
]
}
mocha.opts: mocha.opts:
--require babel-register
--require test/util/dom.js
--require expect
--compilers jsx:babel-register
Answer taken from weinand . 答案取自weinand 。
You also need a .babelrc file in your root app with the "retainLines": true
. 你还需要一个带有
"retainLines": true
root应用程序中的.babelrc文件"retainLines": true
。 Here is my .babelrc file for example: 这是我的.babelrc文件,例如:
{
"presets": [
"es2015",
"stage-2",
"react"
],
"plugins": [
"transform-es2015-modules-umd"
],
"retainLines": true
}
If you get bad option: --inspect=...
, try and installing a newer version of node. 如果您
bad option: --inspect=...
,请尝试安装较新版本的节点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.