Skip to content

Instantly share code, notes, and snippets.

@paambaati
Last active May 5, 2022 05:35
Show Gist options
  • Save paambaati/54d33e409b4f7cf059cc to your computer and use it in GitHub Desktop.
Save paambaati/54d33e409b4f7cf059cc to your computer and use it in GitHub Desktop.
Debug mocha tests using Visual Studio Code
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "app.js",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Environment variables passed to the program.
"env": { "NODE_ENV": "production"}
},
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run mocha",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "/Users/gp/Projects/evol_dealermgmt/node_modules/mocha/bin/_mocha",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": ["test/unit.js"],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Environment variables passed to the program.
"env": { "NODE_ENV": "production"}
}
]
}
@nsa-itv
Copy link

nsa-itv commented Sep 1, 2019

Didn't work for me - if I add the =xxxx (port number) after --inspect-brk, then I get SyntaxError: .../.vscode/launch.json: Unexpected token / in JSON at position 6.

If I don't add it, it tries port 9229, which is not available, regardless of the separate port: xxxx in the json configuration.

@e5pe
Copy link

e5pe commented Aug 7, 2020

FYI on Win10 (VSC 1.18, node 6.9.4 my current working Debugging config:

    {
	"name": "Run mocha",
	"type": "node",
	"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
	"args": ["${workspaceFolder}/test/**/*.spec.js"],
        "request": "launch",
        "outFiles": [
          "${workspaceFolder}/**/*.js"
        ]
    }

Thank you! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment