Lesson:7: Error wile testing fund() function at 11:21 #1257
-
getting this error when i used expect from chai const { deployments, ethers, getNamedAccounts } = require("hardhat");
const { assert, expect } = require("chai");
describe("FundMe", async function () {
let fundMe;
let deployer;
beforeEach(async function () {
const deployer = (await getNamedAccounts()).deployer;
await deployments.fixture(["all"]);
fundMe = await ethers.getContract("FundMe", deployer);
mockV3Aggregator = await ethers.getContract("MockV3Aggregator", deployer);
});
describe("constructor", async function () {
it("sets the aggregator address correctly", async function () {
const response = await fundMe.priceFeed();
assert.equal(response, mockV3Aggregator.address);
});
});
describe("fund", async function () {
it("fails if you dont 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.
Answered by
alymurtazamemon
Jul 24, 2022
Replies: 2 comments 6 replies
-
Try revertedWithCustomError instead of revertedWith. This should fix your issue. Let me know! |
Beta Was this translation helpful? Give feedback.
4 replies
-
"You need to spend more ETH" Your this message is different in the smart contract check that and make sure it is similar. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
ritesh798
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ritesh798
"You need to spend more ETH"
Your this message is different in the smart contract check that and make sure it is similar.