You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often run into the issue where I often forget where the await is supposed to be
e.g.
this is how its supposed to be:
if I'm expecting "foo" to be emitted this will fail await expect (contFoo.foo()).to.emit(contFoo, "fooEvent").withArgs('not FOO')
but if I misplace the await like so expect (await contFoo.foo()).to.emit(contFoo, "fooEvent").withArgs('not FOO')
this will pass, and I get no error message of any kind, or a hint that I might have misplaced the await
So I'm wondering if a warning could be spat out instead of giving a false pass?
thanks
The text was updated successfully, but these errors were encountered:
rzadp
changed the title
misplacing the await for a emit with args should probably error or warn the user
Missing await outside of expect should probably error or warn the user
Jul 29, 2022
Please note that this options (2 awaits): await expect (await contFoo.foo()).to.emit(contFoo, "fooEvent").withArgs('not FOO')
will correctly catch the error, and this one (0 awaits): expect (contFoo.foo()).to.emit(contFoo, "fooEvent").withArgs('not FOO')
will give a false pass.
So it's not a problem of a misplaced await, it's a problem of a missing the left-most await outside of the expect.
I suspect the problem is with mocha finishing the tests and exiting with success, even though our expect is still being executed. I'm not sure we can do anything with this with our current implementation - but I will leave the issue in case anyone else has some idea.
I often run into the issue where I often forget where the
await
is supposed to bee.g.
this is how its supposed to be:
if I'm expecting "foo" to be emitted this will fail
await expect (contFoo.foo()).to.emit(contFoo, "fooEvent").withArgs('not FOO')
but if I misplace the
await
like soexpect (await contFoo.foo()).to.emit(contFoo, "fooEvent").withArgs('not FOO')
this will pass, and I get no error message of any kind, or a hint that I might have misplaced the await
So I'm wondering if a warning could be spat out instead of giving a false pass?
thanks
The text was updated successfully, but these errors were encountered: