PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 182 forks source link

Timeout of 40000ms exceeded. For async tests and hooks, ensure "done()" is called #136

Open hashim715 opened 1 year ago

hashim715 commented 1 year ago

I am receiving this error again and again even after including
mocha: { timeout: 500000, // 500 seconds max for running tests }

lagahrajan commented 1 year ago

mostly bcoz performUpkeep is never called i tried with 1000 sec too but its not working. Even when i use chainlink subscription id mentioned in gitrepo

usaamatahir commented 1 year ago

I am receiving this error again and again even after including mocha: { timeout: 500000, // 500 seconds max for running tests }

I think you are testing locally and added blockConfirmation of value 5. If its the case, its happening because of that. Because on local host its it wait for more blocks to mine but in actuall no blocks are mined. So you can make it 1 for localhost and 5 or whatever for testnet and it will work

Nikhil8400 commented 11 months ago

Share your repo

umair-sidd commented 9 months ago

I am facing the same issue and have not found any solution yet.

const { network, ethers } = require("hardhat") const { developmentChains, networkConfig } = require("../helper-hardhat-config") const { assert, expect } = require("chai")

!developmentChains.includes(network.name) ? describe.skip : describe("Raffle Unit Tests", async () => { let raffle, vrfCoordinatorV2Mock, chainId chainId = network.config.chainId

      beforeEach(async function ({ getNamedAccounts, deployments }) {
          const { deployer } = getNamedAccounts()
          await deployments.fixture(["all"])
          raffle = await ethers.getContract("Raffle", deployer)
          vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock", deployer)
      })

      describe("constructor", async function () {
          it("Initializes the constructor correctly .. ", async function () {
              //Ideally we should only have 1 assert per it statement.
              const raffleState = await raffle.getRaffleState()
              const interval = await raffle.getInterval()
              assert.equal(raffleState.toString(), "0")
              assert.equal(interval.toString(), networkConfig[chainId]["interval"])
          })
      })
  })