• 0

Debug mocha using visual studio code


Add the following configuration 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 message similar 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