【发布时间】:2016-01-26 17:53:19
【问题描述】:
我正在尝试使用 Visual Studio 代码调试 mocha 测试。我正在使用附加方法,它曾经可以工作。它看起来像在它附加的新版本中,在进入时停止,然后在我按继续时忽略所有断点。
还有其他人比这更好吗?
【问题讨论】:
标签: mocha.js visual-studio-code
我正在尝试使用 Visual Studio 代码调试 mocha 测试。我正在使用附加方法,它曾经可以工作。它看起来像在它附加的新版本中,在进入时停止,然后在我按继续时忽略所有断点。
还有其他人比这更好吗?
【问题讨论】:
标签: mocha.js visual-studio-code
我在这里回答了一个类似的问题:https://stackoverflow.com/a/40687741/4331142。简而言之,这是我的 VS Code launch.json 文件,我可以调试 mocha 单元测试。
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/server.js",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
},
{
"type": "node",
"request": "launch",
"name": "Debug Mocha Test",
"port": 5858,
"runtimeArgs": ["${workspaceRoot}/node_modules/mocha/bin/mocha"],
"cwd": "${workspaceRoot}",
"args": ["--recursive", "--debug-brk"]
}
]
}
【讨论】: