Test helpers API


I’ve just released the first non-beta version of the test helpers package (v0.1.1) for people to start using: OpenZeppelin will feature it on the master branch once #1601 goes in.

What I’d like to work next is on the API: it’s a bit all over the place regarding conventions (shouldFail and expectEvent), and IMO would greatly benefit from some polishing. We could e.g. choose to provide helpers for both of chai’s should and expect style, or be more opinionated about it and only do a single one (in which case I’d go for expect).

Other small bits that could use some improvement are functions such as balance.difference, which requires a function to be created in place, leading to somewhat ugly code.

Finally, I’d like to hear ideas for either new test helpers or improvements to the current ones: @remon-nashid 's shouldFail.reverting.withMessage is a great example of this.


+1 to consolidating on either should or expect style. We’ve talked about moving our test suite to expect style but we’ve done so much refactoring in the past few months that I don’t think it’s the moment to make the switch. So I think I would consolidate on should for the helpers for now.

I’d personally like to challenge if using the package should be so magical. This is a part of the API too. For example, requiring the package sets up Chai’s should style, which is quite intrusive because it monkey patches all native JavaScript objects. Could the helpers be used by themselves without doing this setup first? And if we keep the magic, it should be very clear in the documentation in the README.

I’ve also made a proposal to redesign balance.difference.