Lesson 7 - Hardhat - FundMe (1st unit test)- TypeError: fundMe.priceFeed is not a function #2827
-
Hi there, I have been trying to get FundMe.test.js working and I am failing at the first hurdle. This is the error message I am getting when running $ yarn hardhat test. const { assert } = require("chai")
const { deployments, ethers, getNamedAccounts } = require("hardhat")
describe("FundMe", async function() {
let fundMe
let deployer
let mockV3Aggregator
beforeEach(async function() {
// deploy FundMe contract using hardhat deploy
// const accounts = await ethers.getSigners()
// const accountZero = accounts[0]
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 addresses correctly", async function() {
const response = await fundMe.priceFeed()
assert.equal(response, mockV3Aggregator.address)
})
})
}) Let me know if you need me to do anything regarding this. Any help on this comes much appreciated thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
Hey @SimSimButDifferent please share your fundme.sol contract code. |
Beta Was this translation helpful? Give feedback.
-
@SimSimButDifferent You do not have priceFeed function in your fund me contract. This variable is private; AggregatorV3Interface private s_priceFeed; so create a getter function for it with the same name in fund me contract that you are accessing in your tests. function priceFeed() public view returns(address) {
return s_priceFeed;
} |
Beta Was this translation helpful? Give feedback.
-
Is this resolved? |
Beta Was this translation helpful? Give feedback.
Hey @SimSimButDifferent please share your fundme.sol contract code.