📝 Require t.throwsAsync() and t.notThrowsAsync() to be awaited.
💼 This rule is enabled in the ✅ recommended config.
🔧 This rule is automatically fixable by the --fix CLI option.
When you use the t.throwsAsync() and t.notThrowsAsync() assertions, you must await the promise they return. If the test function completes before the assertions do, the test will fail.
This rule is fixable inside async functions. It will insert await before t.throwsAsync() and t.notThrowsAsync().
import test from 'ava';
// ❌
test('main', t => {
t.throwsAsync(somePromise);
t.notThrowsAsync(somePromise);
});
// ✅
test('main', async t => {
await t.throwsAsync(somePromise);
await t.notThrowsAsync(somePromise);
const p = t.throwsAsync(somePromise);
t.throwsAsync(somePromise).then(…);
});