This question already has an answer here:

Im testing wheter a require function does its job by reverting and want to test in within a truffle test.

  it("The URI should be unique", async () =>{

    const dupURI = await token.mintUniqueTweetTo(account1, tokenUri1, {from: accounts[0]}); // Mint a new token


The thing is that when the require reverts I get the following error:

Error: Transaction: 0xaf416881ff8627e6fe5fe6eaed2512035d7b7e659aeb0638e2f1bd362f380d57 exited with an error (status 0).
Please check that the transaction:
    - satisfies all conditions set by Solidity `require` statements.
    - does not trigger a Solidity `revert` statement.

And my test does not continue, does anybody have an idea on how to fix this?

marked as duplicate by Raghav Sood, Achala Dissanayake, Ismael, Richard Horrocks, flygoing Aug 6 '18 at 19:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Easiest approach is to wrap the line:
const dupURI = await token.mintUniqueTweetTo(account1, tokenUri1, {from: accounts[0]});
in a try / catch block and then check that the catch block was executed.

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