Open eric573 opened 1 year ago
I also have the very same issue... Still haven't managed to debug yet, let you know if I do.
Hi! By removing the await before the expect statement solved the issue for me:
expect(attackerConnectedContract.withdraw()).to.be.revertedWith(
"FundMe__NotOwner"
);
You can also use the method revertedWithCustomError(contract, "custom_error_name")
await expect(
attackerConnectedContract.withdraw()
).to.be.revertedWithCustomError(fundMe, "FundMe__NotOwner");
Oh thanks. I had the same issue and solved by this suggestion .
I encountered a weird issue while writing the
Only allows the owner to withdraw
test. More specifically, I get the an assertion error stating that the expected assertions wasn't seen.Test Failure Message
Unit Test Code
FundMe.sol modifier details
What I did to debug Added a console.log statement to ensure that the error thrown is indeed FundMe__NotOwner, and I have the following observation. The code
console.log(await attackerConnectedContract.withdraw())
generates this ouputBased on this observation, I know that the FundMe__NotOwner() error is being thrown, however, the testing framwork wasn't able to pick up on this error type. How should I go about this?