Debug mocha.js with VSCode

This is my cheat sheet for debugging the mocha.js project from VSCode while adding fixes to it. This is not about how to debug ANY project that is using mocha for testing.

The mocha.js repository has a build system that builds into /bin/mocha.

I don't use a package.json script. I just use a launch.json mocha test configuration:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/bin/_mocha",
"args": [
"--colors",
"${workspaceFolder}/test/reporters/dina.spec.js"
],
"internalConsoleOptions": "openOnSessionStart"
}
]
}


  • The program value has to be changed from the node_modules directory to the /bin directory. The top level file is supposed to be bin/_mocha but it won't debug. 
  • Remove any timeout args from the args array. 
  • Specify the exact file you want to debug into such as "dina.spec.js"

Popular posts from this blog

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

Yet once more into the breech (of altered programming logic)

Error : /ScriptResource.axd : Invalid viewstate.