From 7934a5600d243d1ea9fc5835b54fab088b7629d3 Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Fri, 18 Mar 2022 10:57:17 +0100 Subject: [PATCH] feat: add Flame compatibility to test navigator helper --- test/helpers/navigator.dart | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/helpers/navigator.dart b/test/helpers/navigator.dart index d919cdb3..80c53647 100644 --- a/test/helpers/navigator.dart +++ b/test/helpers/navigator.dart @@ -1,9 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:very_good_analysis/very_good_analysis.dart'; import 'helpers.dart'; -Future expectNavigatesTo(WidgetTester tester, Route route) async { +Future expectNavigatesTo( + WidgetTester tester, + Route route, { + bool hasFlameGameInside = false, +}) async { // ignore: avoid_dynamic_calls await tester.pumpApp( Scaffold( @@ -21,7 +26,14 @@ Future expectNavigatesTo(WidgetTester tester, Route route) async { ); await tester.tap(find.text('Tap me')); - await tester.pumpAndSettle(); + if (hasFlameGameInside) { + // We can't use pumpAndSettle here because the page renders a Flame game + // which is an infinity animation, so it will timeout + await tester.pump(); // Runs the button action + await tester.pump(); // Runs the navigation + } else { + await tester.pumpAndSettle(); + } expect(find.byType(Type), findsOneWidget); }