Truffle tests | event trapper | catch event
1 min readJul 10, 2019
Theory and concepts
- Truffle uses Web3 library https://www.trufflesuite.com/docs/truffle/quickstart#interacting-with-the-contract
- Your contracts can fire events that you can catch to gain more insight into what your contracts are doing. The easiest way to handle events is by processing the
logs
array contained withinresult
object of the transaction that triggered the event. https://www.trufflesuite.com/docs/truffle/getting-started/interacting-with-your-contracts#catching-events - Contract methods and events have an EventEmitter interface. So you can set up handlers like the following:
- See the event in the logs of a transaction https://www.trufflesuite.com/docs/truffle/reference/contract-abstractions#making-a-transaction-via-a-contract-function