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.

Matthew
  • 81
  • 5
  • This may be out of scope for the original question, but any pointers to help debuggin truffle tests in IntelliJ would be awesome :-) – TripleSpeeder Jul 02 '17 at 10:21
  • @TripleSpeeder Have a look - https://ethereum.stackexchange.com/questions/41094/debugging-js-unit-tests-with-truffle-framework-in-vs-code/43633#43633 - links to VS Code and node inspsector in Chrome dev tools... – Mars Robertson Apr 04 '18 at 12:33

1 Answers1

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.

0xcaff
  • 2,477
  • 1
  • 14
  • 29