You can and should test errors/transaction reverts.

Use waffle matcher or to additionally test specific revert reason text.

Simple example on ERC-20 funds transfer that exceeds balance trial



An example with a require that is extended with custom user-defined message.

It is great that this very message can be tested against such that we are sure the rejection reason
is exactly what we imagined.

Require with user-defined custom reason and unit test:


Custom function modifier

An example with require that is part of custom function modifier. The modifier is not tested itself,
but its usage is tested on a function.