Skip to content

Commit

Permalink
🧙 Show error when reverts on expect(...).not.to.be.reverted (#587)
Browse files Browse the repository at this point in the history
Co-authored-by: Przemyslaw Rzad <roopert7@gmail.com>
  • Loading branch information
vanruch and rzadp committed Mar 25, 2022
1 parent d1af8bb commit 7992daf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion waffle-chai/src/matchers/reverted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function supportReverted(Assertion: Chai.AssertionStatic) {
this.assert(
isReverted || isThrown || isError,
`Expected transaction to be reverted, but other exception was thrown: ${error}`,
'Expected transaction NOT to be reverted',
`Expected transaction NOT to be reverted, but it was reverted with "${message}"`,
'Transaction reverted.',
error
);
Expand Down
3 changes: 2 additions & 1 deletion waffle-chai/test/matchers/reverted.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ describe('INTEGRATION: Matchers: reverted', () => {
it('Not to revert: fail', async () => {
await expect(
expect(matchers.doThrow()).not.to.be.reverted
).to.be.eventually.rejected;
// eslint-disable-next-line max-len
).to.be.eventually.rejectedWith('Expected transaction NOT to be reverted, but it was reverted with "VM Exception while processing transaction: invalid opcode"');
});

it('Revert: fail, random exception', async () => {
Expand Down

0 comments on commit 7992daf

Please sign in to comment.