Unit test error with mocha and chai Timeout of 2000ms exceeded. For async tests and hooks

南楼画角 提交于 2019-12-11 16:05:08

问题


My code:

const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const { interface,bytecode} = require('../compile');

let accounts;
let inbox;

beforeEach( async() => {
accounts = await web3.eth.getAccounts();
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 a contract', () => {
    console.log(inbox);
 })
})

The error while running it using npm run test:

`shreyas@shreyas-Inspiron-3520:~/inbox$ npm run test

inbox@1.0.0-beta.55 test /home/shreyas/inbox mocha

inbox 1) "before each" hook for "deploys a contract"

0 passing (2s) 1 failing

1) "before each" hook for "deploys a contract": Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)

I searched for solution in so many similar questions, but none of them helped me. Please help. I already spent hours on this issue.

Git Repository of my project: https://github.com/shreyasjain/inbox

来源:https://stackoverflow.com/questions/56417229/unit-test-error-with-mocha-and-chai-timeout-of-2000ms-exceeded-for-async-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!