-
|
Hi I need help here. I`m testing FundMe constructor and having this error: FundMe
constructor
1) "before each" hook for "sets the aggregator addresses correctly"
0 passing (956ms)
1 failing
1) FundMe
"before each" hook for "sets the aggregator addresses correctly":
TypeError: Cannot read properties of undefined (reading 'getContract')
at Context.<anonymous> (test/unit/FundMe.test.js:17:31)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)code FundMe.test.js looks like this: const { network, deployments, getNamedAccounts } = require("hardhat")
const { ethers } = require("hardhat")
const { assert } = require("chai")
describe("FundMe", async function () {
let fundMe
let mockV3Aggregator
let deployer
beforeEach(async function () {
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)
})
})
})how can I solve this TypeError problem? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
|
Hi @joonsun4u Please show me your |
Beta Was this translation helpful? Give feedback.
-
|
@joonsun4u run this command and then try if you are using yarn if you are using npm |
Beta Was this translation helpful? Give feedback.
-
|
@joonsun4u Is it resolved? If yes then please mark the answer otherwise leave your repository link, and I will look into it. |
Beta Was this translation helpful? Give feedback.
I fixed it after installing this:
yarn add --dev hardhat @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers