Lesson 7: "1) TypeError: Cannot read properties of undefined (reading 'length') #2085
-
The issue is copied below, I am facing it when I am trying to run FundMe.test.js
My mock.js file is: const { network } = require("hardhat")
const {
developmentChains,
DECIMAL,
INITIAL_ANSWER,
} = require("../helper-hardhat-config")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
if (developmentChains.includes(network.name)) {
log("Local network detected! Deploying mocks...")
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMAL, INITIAL_ANSWER],
})
log("Mocks Deployed")
log("_________________________________________________________")
}
}
module.exports.tags = ["all", "mocks"] The FundMe.test.js file is: const { deployments, ethers, getNamedAccounts, network } = require("hardhat")
const { assert } = require("chai")
describe("FundMe", async function () {
let fundMe
let deployer
let mockV3Aggregator
beforeEach(async function () {
//deploying out FundMe ocntrac using hardhat-deploy
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)
})
})
}) It seems the error is in line 11 which is Also, this is my third error in a day, so could anyone please tell me what exactly am I doing wrong? Because I faced my same error deploying deploy.fundMe.js on hardhat, then I installed all the dependencies and the code worked. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
@ashrth Make sure you have this in your hardhat.config.js file: namedAccounts: {
deployer: {
default: 0,
},
player: {
default: 1,
},
}, |
Beta Was this translation helpful? Give feedback.
-
Could you share your helper config please? |
Beta Was this translation helpful? Give feedback.
-
Hey @ashrth i've checked your repo and there seems to be an error in your hardhat.config.js file. You had misplaced a closing |
Beta Was this translation helpful? Give feedback.
Hey @ashrth i've checked your repo and there seems to be an error in your hardhat.config.js file. You had misplaced a closing
}
Check the PR i made. Hope this helps