For example, testing for a transaction that reverted or an out of gas error etc.
What is the best practice for writing such tests? Specifically, I am using truffle test framework (mocha/chai).
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityFor example, testing for a transaction that reverted or an out of gas error etc.
What is the best practice for writing such tests? Specifically, I am using truffle test framework (mocha/chai).
You can use Waffle's built-in Chai matchers to test for events, reverts, etc. It works with Truffle and Mocha out of the box, and supports any network provider with history support (like Ganache, BuidlerVM). You can find documentation here:
There are also experimental Jest matchers if you're looking to use Jest instead of Mocha and Chai.