truffle-core
truffle-core copied to clipboard
Add --show-events flag to test command
Flag to show events when tests are passing described in waffle 186.
truffle test --show-events
I'd love to be able to use this.
bump!
independently i implemented a similar hack in my code, and i am loving it. effectively it acts as a console.log()
in solidity. i just emit a custom event with a specified value whenever i wanna inspect a value while testing -- note: the transaction must succeed to see the event log. it's especially helpful when working with private functions and contracts that send messages to one another.
event _UintLog(string name, uint value);
function resolveChallenge(uint _challengeID) private {
// grab values from struct in voting contract
var (,,,votesFor, votesAgainst) = voting.pollMap(_challengeID);
emit _UintLog("votesFor", votesFor);
emit _UintLog("votesAgainst", votesAgainst);
// ...
}
Events emitted during test:
---------------------------
# ... other events
_UintLog(name: votesFor, value: 10)
_UintLog(name: votesAgainst, value: 15)
I feel dumb (new to git). But how do I implement this? I have the latest truffle using npm install -g truffle
I'm using truffle test --show-events
and not getting any events other than those that failed.