我正在尝试使用visual studio代码调试mocha测试。我正在使用attach方法,它曾经工作过。它看起来像它附加的新版本,在进入时停止,然后当我按下继续时忽略所有断点。
还有其他人有更好的运气吗?
答案 0 :(得分:1)
我在这里回答了一个与此类似的问题: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"]
}
]
}