Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 884 Bytes

no-async-fn-without-await.md

File metadata and controls

33 lines (21 loc) · 884 Bytes

Ensure that async tests use await

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

import test from 'ava';

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

Pass

import test from 'ava';

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