在 launch.json中更改以下内容,然后在 VS Code 的调试窗口中选择新的配置名称,并单击绿色箭头开始调试您的节点 + mocha 测试!
在 launch.json:中的新配置中
"configurations": [{
"name": "whatever name you want to show in the VS Code debug list",
"type": "node",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/node_modules/mocha/bin/mocha",
"args": ["--debug-brk=5858", "--no-timeouts", "--colors", "test/**/*.js"],
"address": "localhost",
"port": 5858,
// the other default properties that are created for you are fine as-is
}, ...]
Did you know, that you just go into your launch config, put your cursor after or between your other configs and press ctrl-space to get a current, valid mocha config auto-generated?
这对我来说完全没问题,包括在断点停止。
( I also had a prior, now outdated one, that did no longer for various setting-related reasons. )