PatrickAlphaC / hardhat-fund-me-fcc

82 stars 184 forks source link

FundMe fund function unit test throwing error #15

Closed pro123908 closed 2 years ago

pro123908 commented 2 years ago

When doing unit test on fund function of FundMe contract, the test is throwing exception Seems to be issue with revertedWith function

Test code :

 describe("fund", () => {
        it("fails if you don't send enough ETH", async () => {
            await expect(fundMe.fund()).to.be.revertedWith(
                "You need to spend more ETH"
            )
        })
    })

The test has to be passed with a tick mark but it's throwing following exception:

AssertionError: Expected transaction to be reverted with You need to spend more ETH, but other exception was thrown: Error: VM Exception while processing transaction: reverted with reason string 'Didn't send enough!

Can anyone help with this? Thanks

pro123908 commented 2 years ago

Found the issue, actually the revert message i used in contract was "Didn't send enough!" that's why xD