摩卡与猫鼬,异步,等待

Mocha with Mongoose, async, await

我正在使用 mocha 进行测试,在使用 async/await 时我得到

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

我的代码

describe('ClientsMerge', () => {

    it('it should get all clients', async () => {
let clients = await Client.find();
console.log(clients);
    });

});

您可能需要增加 mocha 测试的超时时间

例如:

mocha src/**/*.test.js --timeout 15000