Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 1.03 KB

no-async-fn-without-await.md

File metadata and controls

35 lines (23 loc) · 1.03 KB

Ensure that async tests use await (ava/no-async-fn-without-await)

💼 This rule is enabled in the ✅ recommended config.

Translations: Français

AVA comes with built-in support for async functions (async/await). This allows you to write shorter and clearer tests.

Declaring an async test without using the await keyword means that either a Promise is not awaited on as intended, or that the function could have been declared as a regular function, which is confusing and slower.

This rule will report an error when it finds an async test which does not use the await keyword.

Fail

const test = require('ava');

test('foo', async t => {
	return foo().then(res => {
		t.is(res, 1);
	});
});

Pass

const test = require('ava');

test('foo', async t => {
	t.is(await foo(), 1);
});