1

I'm testing a simple call and expect it to not revert

await expect(swapCall).to.not.be.reverted

The test fails currently and I get a

AssertionError: Expected transaction NOT to be reverted

How do I get hardhat / waffle / chai to display the revert reason?

1 Answer 1

-1

Maybe try using await expect(swapCall).revertedWith('revertMessage')

3
  • Doesn't work with not.be.revertedWith and the test will pass since the tx did not revert with a known message but with some other revert msg/reason.
    – TommyF
    Apr 4, 2022 at 17:41
  • You wanted to display the revert reason, I've shown you how to do it, by putting an arbitrary string in the expected message that is different from the actual one.
    – Franfran
    Apr 5, 2022 at 12:28
  • Or if you're using hardhat, the console.log is very helpful for debugging in such cases
    – Franfran
    Apr 5, 2022 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.