Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 840 Bytes

no-async-fn-without-await.md

File metadata and controls

33 lines (21 loc) · 840 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

const test = require('ava');

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

Pass

const test = require('ava');

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