如何在制作nyc覆盖率报告时使用VSCode进行调试



我试图在运行nyc时进行调试,而不仅仅是在运行mocha测试时,所以我不必每次运行两次测试
VSCode运行覆盖范围并将其显示给我,但它不会停止或验证断点,我如何将其设置为正确调试
这可能吗?

我的发布配置:

{
"type": "node",
"request": "launch",
"name": "Coverge",
"program": "/usr/local/bin/nyc",
"args": [
"${workspaceFolder}/node_modules/mocha/bin/_mocha",
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/tests/*/*"
],
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js"
],
"env": {},
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart"
}

我支持你,兄弟。

由于NYC将子流程作为派生流程运行,因此它将不起作用。但是,您可以运行所谓的复合启动,它实际上运行2个进程,第一个进程连接到正在等待的第二个进程,监听端口(默认为9229(,然后瞧。

{
// Use IntelliSense to learn about possible 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": "Coverage",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/node_modules/.bin/nyc",
"args": [
"-x","test","--reporter=lcov","--reporter=text",
"node", "--inspect-brk",
"./node_modules/.bin/mocha", "test", "--recursive", "--timeout=300000"
]
}
,
{ // https://code.visualstudio.com/Docs/editor/debugging#_launch-versus-attach-configurations
"type": "node",
"name": "AttachMocha",
"request": "attach",
"port": 9229
}
],
// https://code.visualstudio.com/Docs/editor/debugging#_compound-launch-configurations
"compounds": [
{
"name": "NYC/Mocha",
"configurations": ["AttachMocha", "Coverage"]
}
]
}

您将在调试运行列表中看到NYC/Mocha

最新更新