mochaで一部のテストのタイムアウト時間を伸ばす

公開日時
更新日時

mochaを使ってjsのテストを書いていた際に↓のタイムアウトエラーが発生した。

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

一部のテストのみが時間のかかる処理を行っていたので↓のようにして該当のテストのみタイムアウト時間を伸ばすようにした。

it('should success', async function () {
  // heavy test
}).timeout(60 * 1000) // 1 minute timeout

参考


Related #js