0

I was learning about testing smart contract using mocha but stuck on this part

I have tried to resolve it by putting done() function but error persisted. also tried to increase timeout to 10000ms but same error occurred after 10sec.

let accounts;

let inbox;

beforeEach(async () => {

    // Get a list of all accounts

    accounts = await web3.eth.getAccounts();


    //Use one of those accounts to deploy the Contract
    // Assign deployed contract and assigning to inbox

    inbox = await new web3.eth.Contract(JSON.parse(interface))
    .deploy({ data: bytecode, arguments: ['Hi there!'] })
    .send({ from: accounts[0], gas: '1000000' });

});

describe('Inbox', () => {

    it('deploys contract', () =>{

        console.log(inbox);

    });

});

Error Message:

Inbox:

  1. "before each" hook for "deploys contract"

0 passing (2s)

1 failing

  1. "before each" hook for "deploys contract":

    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • how did you specify the timeout? `setTimeout()` won't work if using arrow function https://mochajs.org/#arrow-functions – deerawan Aug 23 '19 at 07:22
  • I actually changed the default timeout for mocha in package.json file this solution was also found from internet but didn't worked – Shahiryar Arif Aug 23 '19 at 07:34
  • Does this answer your question: – Ogubuike Alexandra Jan 19 '23 at 19:31
  • Does this answer your question? [For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves](https://stackoverflow.com/questions/44149096/for-async-tests-and-hooks-ensure-done-is-called-if-returning-a-promise-en) – TylerH Jan 24 '23 at 20:18

0 Answers0