Closed elkSal closed 5 months ago
Solved it, what was causing the issue was this line in the class code
String? hCaptchaToken =
await _router.pushNamed(HCaptchaDialog.routeName);
Working solution is:
final hCaptchaToken =
await _router.pushNamed(HCaptchaDialog.routeName);
Does anyone know why defining the return value type causes such issue? Thanks
I'm guessing it's because of the generic type not matching. Glad you figured it out!
Hi all,
thanks a lot for this great library, it saved me so much time with testing and made testing more enjoyable :P
I am facing the following issue: I am defining what a mock object specific function should perform with the when method but the function doesn't run. I assume the matcher doesn't consider the two functions equal.
I think it might be due to the GoRouter pushNamed extra parameter (the type is "Object?") but even adding the any(named: "extra") doesn't help. I tried without any, with any(named: "extra") and even any(named: "extra", that: isA<Object?>()) with no success.
To Reproduce Class
Test Failing
On another usecase I used the Mocktail when function for a similar case and it worked fine. Successful test:
Error thrown by failing test: type 'Null' is not a subtype of type 'Future<String?>' test/features/auth/domain/usecases/show_hcaptcha_test.dart 7:7 MockGoRouter.pushNamed package:athlas/features/auth/domain/usecases/show_hcaptcha.dart 17:23 ShowHcaptcha.call test/features/auth/domain/usecases/show_hcaptcha_test.dart 32:38 main.