Mocha breakpoints using Visual Studio Code

后端 未结 20 1296
星月不相逢
星月不相逢 2020-12-12 11:52

Is it possible to add breakpoints to ones Mocha tests using Visual Studio Code?

Normally when debugging code one need to configure the launch.json, setting the prog

20条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 12:16

    This is working fro me on a Windows 7 machine. I do have mocha installed globally, but this configuration is pointing to the project install to avoid the need for a user profile path (which btw, I tried used %USERPROFILE% variable with no success). I'm able to set breakpoints in my mocha tests now. Yay!

    {
            "name": "Mocha Tests",
            "type": "node",
            "request": "launch",
            "stopOnEntry": false,
            "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
            "cwd": "${workspaceRoot}",
            "args": ["./test/**/*.js"],
            "runtimeExecutable": null,
            "envFile": "${workspaceRoot}/.env"
        }
    

提交回复
热议问题