smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
11.94k stars 2.89k forks source link

Lesson 7 error : "before each" hook for "should set the aggregator address correctly": TypeError: ethers.getContract is not a function #6484

Open wbshobhit1 opened 4 months ago

wbshobhit1 commented 4 months ago

Discussed in https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/6483

Originally posted by **wbshobhit1** March 6, 2024 `const { assert } = require("chai"); const { getNamedAccounts, deployments, ethers } = require("hardhat"); describe("FundMe", async function () { let fundMe; let deployer; let mockV3Aggregator; beforeEach(async function () { // 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("should set the aggregator address correctly", async function () { const response = await fundMe.priceFeed(); assert.equal(response, mockV3Aggregator.target); }); }); }); ` I am getting this error "TypeError: ethers.getContract is not a function" i have tried all the possible solution present on the StackOverflow and ethetruem stack solution no solution seems to work.
mrxain699 commented 2 months ago

Hello @wbshobhit1 Try ether.getContractFactory("FundMe).then((factory) => factory.deploy(deployer))