I am running a mocha test for a solidity SC. One of my test function should pass and then, just after that i am calling assert(false), but it is not executing.

 it('only manager can call the pickWinner', async () => {
try {
  await lottery.methods.pickWinner().call({
    from: accounts[1],
} catch (err) {

The test is passing even though I am doing assert(false).


Because you're catching the error in your test.

The idea in Mocha is that exceptions are caught at the framework level, not at the "application" level.

A test fails if it throws an exception to the Mocha framework, and passes otherwise.

| improve this answer | |
  • Why the dislike? I think the answer is right – goodvibration Sep 16 '18 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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