6

I am currently developing a Dapp and using truffle test to verify the contract. However, I find that I am also debugging the Javascript that runs the test with a lot of console.log() statements. This is time consuming and inefficient. I would like to use a debugger to examine the Javascript in order to refine my tests, and also because I'm still figuring out how to interact with web3 correctly.

2

Truffle is built on NodeJS so you can use any of node's debugging tools. Here's how you can use node's built in debugger:

$ node --inspect-brk $(which truffle) <truffle args>

or if you installed truffle locally:

$ node --inspect-brk $(npm bin)/truffle <truffle args>

This will execute truffle <truffle args> and break right away. Follow the directions to attach. If you don't want to break right away, replace --inspect-brk with --inspect and use debugger statements.

  • Did you mean "replace --inspect-brk with --inspect"? – Robert Oschler Jun 1 '18 at 15:58
  • @RobertOschler Yes – 0xcaff Jun 7 '18 at 22:09

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.