Issue: I cannot override the default timeout of 40000ms when testing using rinkeby network. I'm getting the error of Timeout of 40000ms exceeded. (Error: Timeout of 40000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise,...) I didn't test with other json-rpc network such as kovan so I can't be certain the issue is present there too

Background: my solidity code is a simple lottery setup and is connected to chainlink oracle to determine usd/eth exchange. I can confirm my solidity code is fine because the test sometimes run fine and is able to return me those values I have consoled.log. Other time, it just give a timeout error

unless the way I setup my test is incorrect, then I think the issue lies in the timeout. Anyone can advise on this? Thanks

"hardhat": "^2.8.2",
"@nomiclabs/hardhat-ethers": "^2.0.4",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"chai": "^4.3.4",

networks: {
    rinkeby: {
      accounts: [
      timeout: 200000,  // <---- issue

describe.only("Lottery", function () {
  let lottery;
  let admin;
  let player1;
  let player2;
  let result;

  before(async () => {
    const Lottery = await ethers.getContractFactory("Lottery");
    lottery = await Lottery.deploy();
    await lottery.deployed();

    [admin, player1, player2] = await ethers.getSigners();

    await lottery.connect(admin).startLottery();

    await lottery.connect(player1).enter({
      value: ethers.utils.parseEther("0.1"),

    // await lottery.connect(player2).enter({
    //   value: ethers.utils.parseEther("0.1"),
    // });

  describe.only("Return Lottery Results", async function () {
    it("Should return lottery", async function () {
      console.log("fee", await lottery.fee());
      console.log("usdEntryFee", await lottery.usdEntryFee());
      //todo function call to a non-contract account
      console.log("getEntranceFee", await lottery.getEntranceFee());
      console.log("randomness", await lottery.randomness());
      console.log("lottery_state", await lottery.lottery_state());
      console.log("players", await lottery.getPlayers());
  • 1
    maybe you need to change the mocha timeout in hardhat config file mocha: { timeout: <time in milli second>, },
    – Majd TL
    Feb 2, 2022 at 9:20

2 Answers 2


setting mocha timeout helped in my case (in hardhat.config.js)

module.exports = {
  mocha: {
    timeout: 100000000
  • 3
    Not possible to set in the test? I onlyhave one of 100 tests which need a timeout over 40MM ms
    – GGizmos
    Jul 27, 2022 at 6:08

Example of increasing timeout for a particular test:

    it('test ...', async function () {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.