Skip to main content

prefer-expect-later

has auto-fix
pro+

Warns when a Future is passed to expect without it being awaited.

Not awaiting a Future passed to expect can lead to unexpected results. Replacing it with expectLater will show a warning for a not awaited Future.

Example

❌ Bad:

Future<void> main() async {
// LINT: Prefer using 'expectLater' with Futures.
expect(Future.value(1), 1);
}

✅ Good:

Future<void> main() async {
await expectLater(Future.value(1), 1);
}