VS代码中的调试

时间:2020-03-17 14:10:01

标签: angular karma-jasmine

我一直在关注有关在VSCode:How to debug Karma tests in Visual Studio Code?中使用 Chrome调试器的帖子。

我的launch.json是这样的:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome",
      "url": "http://localhost:4200",
      "trace": true,
      "webRoot": "${workspaceFolder}/src",
      "sourceMaps": true
    }
  ]
}

我的Karma配置中包含以下内容:

logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeDebugging'],
singleRun: true,
restartOnFileChange: true,
customLaunchers: {
  ChromeDebugging: {
    base: 'Chrome',
    flags: ['--remote-debugging-port=4200']
  }
}

当我从调试面板启动时,它直接进入localhost:4200,但没有达到断点。我是否缺少明显的东西?感谢您提供任何有用的提示。

1 个答案:

答案 0 :(得分:1)

您需要attach而不是launch chrome中的调试器。

Launch.json

将此行从"request": "launch"更改为"request": "attach"

结帐出色的enter image description here