I would like to test async codes with Mocha
.
I followed this tutorial testing-promises-with-mocha. In the end, it says the best way is async/await.
Following is my code, I intended to set setTimeout longer than Mocha default.
describe('features', () => {
it('assertion success', async() => {
const resolvingPromise = new Promise( resolve => {
setTimeout(() => {
resolve('promise resolved')
}, 3000)
})
const result = await resolvingPromise
expect(result).to.equal('promise resolved')
})
})
Mocha give me error as following:
Error: Timeout of 2000ms exceeded. For async tests and hooks,
ensure "done()" is called; if returning a Promise, ensure it resolves...
How to resolve the error? Simple set mocha --timeout 10000
longer?
Thanks for your time!
Mocha: 5.2.0
Chai: 4.2.0