.settings not working 'mocha' in Microsoft Visual Studio Code on Windows


Is it possible to add breakpoints to one’s Mocha tests using Visual Studio Code on Windows 7?

I tried to run a test with the following settings. (See here & here for reference.)

    "name": "Unit tests",
    "type": "node",
    "program": "node_modules/mocha/bin/_mocha",
    "stopOnEntry": false,
    "args": ["test/*.js"],
    "cwd": ".",
    "runtimeExecutable": "C:/Program Files/nodejs/node.exe",
    "env": { }
// Visual Studio Code 0.3.0
// Windows7(64bit)
// node v0.12.2
// [email protected]

But following this an error will be displayed:

can’t launch program ‘c:\Users\xxx\study_mocha\node_modules\mocha\bin_mocha’; enabling source maps might help


I was able to get it to kind of work by hack alert copying _mocha to mymocha.js. Then Code recognizes it as something to run\start. It always runs the test but it doesn’t always hit break points. I’ve found if I "stopOnEntry": true,on entry, then set breakpoints on the describe and it statements, I can hit on break points on the test.

The other tip that I have is that when the tests run, if they all pass the debugger window just closes and you don’t get the satisfaction of seeing the passing tests output. So if, I’m really trying to debug, I put a assert.equal(1,2) so it fails and it will wait for a keypress (and I see the results page).

I know it’s not a great answer. It’s pretty much a work-around for beta software. 0.5.0

            "name": "Classification Tests",
            "type": "node",
            "program": "C:/c2/npm-global/node_modules/mocha/bin/myMocha.js",
            "stopOnEntry": true,
            "args": ["classificationTests.js"],
            "cwd": ".",
            "runtimeExecutable": null,
            "env": { }

Answered By – jeff

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published