PatrickAlphaC / hardhat-fund-me-fcc

82 stars 184 forks source link

Having issues with unit test failing. #156

Closed sameer59-saks closed 1 year ago

sameer59-saks commented 1 year ago

when i run yarn hardhat test i get below error

  1) "before each" hook for "sets the aggregator addresses correctly"

0 passing (1m) 1 failing

1) FundMe "before each" hook for "sets the aggregator addresses correctly": Error: Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/blockchain-javascript/hh-blockchain-js-solidity/hardhat-fund-me-fcc/test/unit/FundMe.test.js) at listOnTimeout (node:internal/timers:564:17) at processTimers (node:internal/timers:507:7)

I have tried following things

  1. changing timeout
  2. Adding done()
  3. Literally copy pasting patrick's code and it still does not work
  4. Tried removing async and added done
  5. Tried chatGPT :). gave the code to it asked for correction the suggestion it comes with is something which takes me to same state.

/// My code is below.

const { deployments, ethers, getNamedAccounts } = require("hardhat")

//const { getNamedAccounts } = require("@nomiclabs/hardhat-ethers/helpers") // Fixed typo here const { assert } = require("chai")

describe("FundMe", async function() { this.timeout(60000) 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(done) {
        // Added async here
        //this.timeout(60000)
        const response = await fundMe.priceFeed()
        assert.equal(response, mockV3Aggregator.address)
        done();
    })
})

})

PatrickAlphaC commented 1 year ago

Can you:

  1. Make this a discusson on the full repo? https://github.com/smartcontractkit/full-blockchain-solidity-course-js/
  2. Follow this section for formatting questions? https://www.youtube.com/watch?t=19846&v=gyMwXuJrbJQ&feature=youtu.be
daniy310 commented 1 year ago

how did you manage to fix this ?