Lesson 7: Error - Invalid Chai property: revertedWith #997
-
I've just reached unit testing the fund function(). On running the test I am receiving the error given above: "Error: Invalid Chai property: revertedWith" I've tried the following steps to debug:
I'm still facing the same error. Please find my FundMe.test.js given below. Any help will be appreciated. const { assert, expect } = require("chai")
const { deployments, ethers, getNamedAccounts } = require("hardhat")
describe("FundMe", async function() {
let fundMe
let deployer
let mockV3Aggregator
beforeEach(async function() {
//const accounts = await ethers.getSigners()
//const accountZero = account[0]
deployer = (await getNamedAccounts()).deployer
await deployments.fixture(["all"]) // deploy all contracts using deployment.fixture()
fundMe = await ethers.getContract("FundMe", deployer)
mockV3Aggregator = await ethers.getContract(
"MockV3Aggregator",
deployer
)
})
describe("constructor", async function() {
it("Should set the aggregator addresses correctly", async function() {
const response = await fundMe.priceFeed()
assert.equal(response, mockV3Aggregator.address)
})
})
describe("fund", async function() {
it("Should fail if you don't send enough ETH", async function() {
await expect(fundMe.fund()).to.be.revertedWith(
"You need to spend more ETH!"
)
})
})
}) |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 20 replies
-
Did you do this? |
Beta Was this translation helpful? Give feedback.
-
@Mark-Four Do you have |
Beta Was this translation helpful? Give feedback.
-
@Mark-Four and @alymurtazamemon Thank you for the necessary discussion and guidance. |
Beta Was this translation helpful? Give feedback.
-
Try to reinstall the hardhat choosing the latest version -2.0.3 |
Beta Was this translation helpful? Give feedback.
-
Hi @Mark-Four @alymurtazamemon I am running into the same error. I have run yarn add ethereum-waffle . But the error still persists, if I require ethereum waffle in the hardhat config i get this error-
How did you solve this issue could you guide me? |
Beta Was this translation helpful? Give feedback.
@Mark-Four Do you have
ethereum-waffle
along with@nomiclabs/hardhat-waffle
?