Debug mocha using visual studio code


Add the fol­low­ing con­fig­u­ra­tion in your launch.json

        {
            "name": "Run mocha",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/node_modules/mocha/bin/mocha",
            "stopOnEntry": false,
            "args": [
                "test/**/*.js",
                "--inspect",
                "--debug-brk",
                "--no-timeouts"
            ],
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": null,
            "env": {
                "NODE_ENV": "testing"
            }
        },

You should see a mes­sage sim­i­lar to the following:

To start debugging, open the following URL in Chrome:
    chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf12346aec5f281230/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/4963c15c-dd46-473e-a94c-7a3234332140f


You may also like...