PatrickAlphaC / hardhat-fund-me-fcc

82 stars 183 forks source link

AssertionError: Expected transaction to be reverted with reason 'FundMe__NotOwner', but it reverted with a custom error #138

Open haris4121 opened 1 year ago

haris4121 commented 1 year ago

after writing test

it("only allows owner to withdraw", async () => {
            const accounts = await ethers.getSigners()
            const fundMeConnectedContract = await fundMe.connect(accounts[1])
            await expect(fundMeConnectedContract.withdraw()).to.be.revertedWith(
                "FundMe__NotOwner"
            )
        })

it gives error as

  AssertionError: Expected transaction to be reverted with reason 'FundMe__NotOwner', but it reverted with a custom error

but if i write test with out revert messege it passes

it("only allows owner to withdraw", async () => {
            const accounts = await ethers.getSigners()
            const fundMeConnectedContract = await fundMe.connect(accounts[1])
            await expect(fundMeConnectedContract.withdraw()).to.be.reverted
        })
Wonder0xWeird commented 1 year ago

I'm having the same issue, running the typescript version, thinking it could be a typing issue?

Wonder0xWeird commented 1 year ago

Answer is here @haris4121:

https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/130