Last active
March 16, 2019 18:37
-
-
Save raineorshine/a179b3eea3466fb1db5d8213e047903a to your computer and use it in GitHub Desktop.
Asserting solidity throws in truffle tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should throw an error', cb => { | |
const result = aMethodThatRejects() | |
result.then(x => { cb('Expected error. Instead got ' + x) })) | |
result.catch(() => cb()) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In newer versions of node, the originally suggested approach will result in unhandled rejections. They can be suppressed, but a cleaner approach is one of the following:
Promise:
With Chai:
Reference: https://gist.github.com/haroldtreen/5f1055eee5fcf01da3e0e15b8ec86bf6