Mocha breakpoints using Visual Studio Code

后端 未结 20 1295
星月不相逢
星月不相逢 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:28

    Simplest solution

    Add the following code to the launch.json inside the .vscode folder :

    {
                "name": "Unit tests",
                "type": "node",
                "request": "launch",
                "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
                "args": [
                ],
            }
    

    You might want however to add a timeout argument as well:

     {
                "name": "Unit tests",
                "type": "node",
                "request": "launch",
                "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
                "args": [
                    "--timeout",
                    "999999"
                ],
            }
    

提交回复
热议问题