Debug mocha tests with Visual Studio Code easily

This is a really simple tip, but a load of our developers were kicking off a run of their tests by the command line, and then attaching the VSCode debugger to them to step through. VSCode offers a much easier solution to this.

Instead of doing something like this


then hitting F5 and attaching your debugger to the running process. You can set up a configuration in your launch.json file to debug these by just hitting F5.


But you don’t have to edit the file manually. VSCode does the work for you.


If you go to the debug tab in VSCode on the left hand side, then drop down the list beside the “play” button, you will have the option to “Add Configuration” click this and you will get a list of options.


This will auto populate your launch.json file for you. You can edit the default values here to suit your file structure, and use filters to only run certain files.

i.e. only files that end with .test.js etc..

This will instantly show up in your “Launch” dropdown beside the play button, and you can add breakpoints and step through your tests easily at the press of a button!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: