I am using visual studio code and truffle and would like to easily debug my JavaScript tests.

A similar question has been asked here: how can I run a truffle test in a debugger?. This has been wrongly marked as a duplicated and not been released.


Add the following to your configurations in launch.json:

"configurations": [
            "name": "run tests",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/node_modules/truffle/build/cli.bundled.js",
            "args": ["test"],
            "cwd": "${workspaceRoot}",
            "outFiles": [

You will need to adjust the program property to match the path of your installed truffle if you have installed truffle globally.

| improve this answer | |
  • That doesn't seem to run the tests for me. – Daniel Ryan Aug 15 '18 at 22:01
  • 2
    It worked for me after I installed truffle as a local package – ulu Jan 20 '19 at 10:21

Clearly, if you have installed truffle globally (npm install -g truffle), you will need to provide the full path of that directory e.g.: "program": "/usr/local/lib/node_modules/truffle/build/cli.bundled.js"

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.