PatrickAlphaC / hardhat-fund-me-fcc

82 stars 182 forks source link

Getting Error while running tests "TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')" #146

Closed usaamatahir closed 1 year ago

usaamatahir commented 1 year ago

I'm working on fundme and its deploying well on localhost but when I run test it gives me error 1) FundMe "before each" hook for "sets the aggregator addresses correctly": TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider') Here is the repo link https://github.com/usaamatahir/fundme-hardhat

Here is the Code for test

`const { assert } = require("chai"); const { deployments, ethers, getNamedAccounts } = require("hardhat");

describe("FundMe", async function () { let fundMe; let deployer; let MockV3Aggregator; 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.getPriceFeed(); assert.equal(response, MockV3Aggregator.address); }); }); });

`

zeeshan615 commented 1 year ago

getting same error.. trying to solve for two days.

usaamatahir commented 1 year ago

getting same error.. trying to solve for two days.

Please post here if you find any solution. I'll do the same. Thanks

zeeshan615 commented 1 year ago

getting same error.. trying to solve for two days.

Please post here if you find any solution. I'll do the same. Thanks

sure

usaamatahir commented 1 year ago

I have resolved this by install specific version of ethers@5.0.0 and importing @nomiclabs/hardhat-ethers in hardhat.config.ts