Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 1.03 KB

File metadata and controls

33 lines (23 loc) · 1.03 KB

ava/use-t-throws-async-well

📝 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().

Examples

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