Skip to main content

avoid-async-callback-in-fake-async

added in: 1.9.0
🛠
Pro+

Warns when an async callback is passed to FakeAsync.

FakeAsync implementation does not await an async callback and the test will pass even if it should not.

Example

❌ Bad:

void main() {
// LINT: Async callbacks passed to 'FakeAsync' are not awaited making the test to always pass. Try removing the 'async' keyword.
FakeAsync().run((fakeAsync) async {
...
});

// LINT: Async callbacks passed to 'FakeAsync' are not awaited making the test to always pass. Try removing the 'async' keyword.
fakeAsync((fakeAsync) async {
...
});
}

✅ Good:

void main() {
FakeAsync().run((fakeAsync) {});

fakeAsync((fakeAsync) {});
}