如何为异步等待功能修复此“在每个钩子之前”?

时间:2019-08-23 00:10:43

标签: async-await mocha web3

我正在学习有关使用Mocha测试智能合约的知识,但是停留在这一部分

我试图通过放置done()函数来解决它,但错误仍然存​​在。 还尝试将超时时间增加到10000ms,但10秒后发生了相同的错误。

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);

    });

});

错误消息:

收件箱:

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

0传球(2s)

1个失败

1)“部署合同”的“之前”钩子:

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

0 个答案:

没有答案