Replies: 2 comments 1 reply
-
Hi @abra, I'm not sure of the correct solution, but the logs say to "provide your own HttpClient implementation". This can be done by passing one into the a |
Beta Was this translation helpful? Give feedback.
1 reply
-
This worked for me extension on WidgetTester {
Future<void> pumpWithDeps() async {
final mockTileProvider = MockTileProvider();
when(mockTileProvider.headers).thenReturn({ });
when(mockTileProvider.supportsCancelLoading).thenReturn(false);
when(mockTileProvider.getImage(any, any)).thenReturn(IN_MOMORY_IMAGE);
//when(mockTileProvider.getImage(any, any)).thenReturn();
final bloc = GISBloc(const MockGraphQLClient(), UnitsGISRepository());
await pumpWidget(MaterialApp(
home: Provider<TileProvider?>.value(
value: mockTileProvider,
child: GISPage(
bloc: bloc,
),
),
));
}
}
@GenerateMocks([TileProvider])
void main() {
group("GIS widget tests", () {
testWidgets("GIS widget renders", (tester) async {
await tester.pumpWithDeps();
expect(find.byType(GISWidget), findsOneWidget);
});
});
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I am writing a widget test for the widget
HomeScreen
which containsPageView
, which in turn containsMapScreen
withFlutterMap
.FlutterApp -> HomeScreen -> PageView -> MapScreen
Test:
Because
FlutterMap
performs HTTP requests, the test fails with the following error:Error:
I understand that you need to intercept the HTTP request
FlutterMap
widget, but how to do this I do not know.Beta Was this translation helpful? Give feedback.
All reactions