-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Truffle doesn't catch error and crashes mocha runner #2497
Comments
Thanks for bringing this up! Sounds like we need an extra |
I'm also having this problem and what I noticed is the weird string being thrown instead of an Error object. The string is And this crashes the test because mocha doesn't support strings being thrown (mochajs/mocha#3321) |
Do you have a specific example that I could use to reproduce this error? If I just make a Solidity function that reverts it doesn't crash the test runner. |
Workaround: Add
after the line
of |
I almost always get this when moving common code into an async helper method and a contract method fails there. Example:
|
I am using: And I can confirm that transaction reverts in Solidity code crashes and exits the truffle environment |
@fainashalts Here is
this is how it ends up 😅
|
Hey @ashajjar this looks kind of similar to a bug we had in a recent version or two of Truffle. Can you upgrade to the latest Truffle (v5.4.31) and see if you still get the error? |
I was only one patch behind 😅 v5.4.30 ... now it works on v5.4.31 🎉 I took me 24 hours of scratching my head!! |
Sorry to cause you trouble! That was the release that included the next major release of Ganache (v7) and we had a bug or two to iron out. Glad your problem was resolved! |
Thanks a lot :) |
Is this still an issue? |
Issue
What the issue is, in broad strokes.
Code:
Truffle test with chai cannot catch revert reason. The try catch block does not work and it crashes the entire runner
Steps to Reproduce
Please provide the shortest amount of steps to reproduce your issue.
Expected Behavior
What you expected to happen.
The test passes
Actual Results
What actually happened. Please give examples and support it with screenshots, copied output or error messages.
Output from ganache-cli:
Related:
mochajs/mocha#3320
The issue seems to be that this thing is throwing a string, an not an object.
Environment
Operating System: ubuntu 18.04
Ethereum client: Ganache CLI v6.7.0-beta.0 (ganache-core: 2.8.0-beta.0)
Truffle version (
truffle version
):Truffle v5.0.41 (core: 5.0.41)
Solidity v0.5.8 (solc-js)
Node v10.5.0
Web3.js v1.2.1
node version (
node --version
): v10.5.0npm version (
npm --version
): 6.12.0The text was updated successfully, but these errors were encountered: