How to debug Unit Tests with Karma/Jasmine in Visual Studio Code?

后端 未结 1 1769
粉色の甜心
粉色の甜心 2021-02-02 17:12

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

{
   \         


        
相关标签:
1条回答
  • 2021-02-02 17:38

    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".

    0 讨论(0)
提交回复
热议问题