Good day,
I'm using mochajs to test my Solidity code using truffle and testrpc.
In my contract I got the following event and function:
contract store{
event MoneyIn (address _from, uint256 _amount);
function getMoney() payable{
//event
MoneyIn(msg.sender, msg.value);
}
}
And this is the mochajs code:
it("Pay to store", function(){
return storeContract.getMoney({from: account[0], value: txAmount}).then(function(res){
assert.isDefined(res);
});
});
It simpally checks if the transaction was executed by checking if the res
is defined.
However, when mocha don't throw errors, it also won't emit the event. The only way in which I can get see my event is my creating an error:
for example I can change the assertion from isDefined(res)
to ifError(res)
.
Doing so will force mocha to throw an error and as a side product it will also emit my event:
1) Pay to store
Events emitted during test:
---------------------------
MoneyIn(_to: 0xa86120c19324a9ed51fe17730fce24edd69ddc9c, _amount: 300000000000000000)
---------------------------
I'll hihgly appriciate any tip you might have on how to force mocha to emit events even when there're no errors.