felangel / mocktail

A mock library for Dart inspired by mockito
https://pub.dev/packages/mocktail
MIT License
617 stars 81 forks source link

while giving header or body to http. mock type 'Null' is not a subtype of type 'Future<Response>' this error coming #224

Closed fimaljo closed 3 months ago

fimaljo commented 9 months ago

type 'Null' is not a subtype of type 'Future' test\webservice\login\feedback_request_test.dart 14:7 MockClient.post feedback_request_test.dart:14 package:choys/src/webservice/feedback/feedback_request.dart 24:35 FeedbackRequest.createFeedback test\webservice\login\feedback_request_test.dart 81:51 main..

maxstubbersfield commented 9 months ago

Hi there, are you adding the headers and/or body to the stub response of the MockClient?

when(() => httpClient.post(any(), headers: any(named: 'headers'), body: any(named: 'body'))).thenAnswer((_) async => response);

fimaljo commented 9 months ago

yes also i used mockito while using that this is the error MissingStubError: 'post' No stub was found which matches the arguments of this method call: post(https://feedback/create, {headers: null, body: null, encoding: null}) but there is no miss match

felangel commented 5 months ago

Hi @fimaljo 👋 Can you please provide a link to a minimal reproduction sample? Thanks!

felangel commented 3 months ago

Closing for now since this issue is quite old and there isn't a minimal reproduction sample. If this is still a problem please file a new issue with a link to a reproduction sample, thanks!