Widget Testing and Flutter 1.20.1

After the upgrade to Flutter 1.20.1 none of my widget tests worked anymore. On investigation I found that my widgets weren’t getting rendered at all, i.e. their build method wasn’t being called. This is a preliminary result but I was doing this in my test:

  await tester
      .pumpWidget(makeTestableWidget(settings, child: WidgetToTest()));
  await tester.pump();

Seems like that no longer works and must now be:

  await tester
      .pumpWidget(makeTestableWidget(settings, child: WidgetToTest()));
  await tester.pumpAndSettle();

I haven’t seen anything in the release notes that suggests this should be required. I’m still investigating but in case this helps someone else I thought I’d put it out there.

Leave a Reply

Your email address will not be published. Required fields are marked *