Closed Kirol54 closed 2 years ago
This library does not work with Ethers.js, only with Web3.js. In order to use with Hardhat, you need to install and use the plugin hardhat-truffle5
.
If working with Hardhat and Ethers is non-negotiable, you might want to look at this simple port of this function for this setup + TypeScript, which powers most of Balancer's tests: https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/pvt/helpers/src/test/expectEvent.ts
I'm running a simple hardhat project with OZ's ERC20 contract and using ether.js to test it and I've encountered a similar issue as #155
Test code:
fails with:
The event can be found when looking at tx receipt return by txResponse.wait();
The workaround I found requires replacing the following line: https://github.com/OpenZeppelin/openzeppelin-test-helpers/blob/9a63072cfe4f72526b76cacde50a0528d75b634a/src/expectEvent.js#L22-L24 which normally returns:
[ { event: '0', args: undefined } ]
with:
return ({ event: receipt.events[name].event, args: receipt.events[name].args });
result:[ {event: 'Approval', args: [......] }]
Obviously not sure what knock-off effect that may have on different projects but thought that may be useful to address the issue quicker
I had to use ethereum-waffle package with it's
expect().to.emit
instead.