I\'d like to be able to debug unit tests in Visual Studio Code, but so far it has been a mixed bag.
My setup:
launch.json
{
\
In karma.conf.js I updated added debug option in your version.
customLaunchers: {
Chrome_with_debugging: {
base: 'Chrome',
flags: ['--remote-debugging-port=9222'],
debug: true
}}
launch.json Add below snippet as launch configuration,
{
"name": "Debug tests",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
Then triggered the tests using below command,
ng test --browsers Chrome_with_debugging
Use Visual Studio Code debug option "Debug tests" to get attached to UT. With this I am able to debug unit tests using breakpoints in "Visual Studio Code + Debugger for Chrome extension".