-
Notifications
You must be signed in to change notification settings - Fork 346
Description
This is a followup to #232, which is now complete.
In Flutter widget tests written with the venerable expect API, it's common to have expectations like
expect(find.whatever(), findsOne);using the matchers findsOne, findsNothing, and findsWidgets. See docs.
We're using package:checks instead, which is the projected, still-beta, successor to expect with a fancy type-safe API, so these "matchers" like findsOne aren't available; and until recently we didn't have great analogues of them. So one thing we currently often do in place of findsOne is
tester.widget(find.whatever());which will indeed throw if there isn't exactly one such widget, but it's not great because it doesn't look like something intended as one of the checks that are the payload of the test — it looks like it's just part of the test's setup (and on top of that, isn't doing anything). A bit of discussion here: #207 (comment)
There's no longer a reason to write expectations that way. Instead we can use the handy new flutter_checks package to write:
check(find.whatever()).findsOne();which is clear that the intent is to check an expectation. It's also a very straightforward translation of the expect form, so it's easy to migrate.
There's no rush to migrate all our existing tests, but this issue is to track eventually doing so. In the meantime we should generally write new tests in the new style.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status