truffle-core icon indicating copy to clipboard operation
truffle-core copied to clipboard

Add --show-events flag to test command

Open p14n opened this issue 7 years ago • 3 comments

Flag to show events when tests are passing described in waffle 186.

truffle test --show-events

p14n avatar Jun 21 '17 18:06 p14n

I'd love to be able to use this.

robertkeizer avatar Sep 28 '17 17:09 robertkeizer

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)

kangarang avatar May 30 '18 21:05 kangarang

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.

syndac avatar Jun 09 '18 01:06 syndac