Closed ykaito21 closed 11 months ago
@ykaito21 One funny thing : You are using mocktail and ended up with this situation. I have used mockito in basically the same way you did with mocktail, but with the same problem as you did have now. I'm starting to think that this is a Riverpod issue.
Hi @ykaito21 👋 Thanks for opening an issue!
Just took a look and I’m guessing the issue is due to lack of correct generic types. In the mocktail test I believe your verify should be:
verify(() => listener(null, any(that: isA<AsyncError<Counter>>()))).called(1);
The reason the mockito tests pass is because afaik mockito doesn’t support verifying with generics whereas mocktail does. Hope that helps 👍
@felangel, Thanks for your comment!
verify(() => listener(null, any(that: isA<AsyncError<Counter>>()))).called(1);
doesn't change the result.
https://github.com/rrousselGit/riverpod/issues/2742#issue-1806700851 might help you understand this issue. I'm not sure this is Riverpod's related issue or not.
They don't support
fn(null, argThat(...))
. It behaves asfn(argThat(...), null)
insteadTry:
listener(any(that: null), any(that: isA<loading>()))
Remi helped me solve the issue https://github.com/rrousselGit/riverpod/issues/2742#issuecomment-1645551241.
I have encountered an issue when using Mocktail with Riverpod and AsyncValue for testing. The problem occurs when I'm attempting to verify that a listener was called with specific arguments.
I have two identical tests. One uses Mockito and passes successfully, but the other uses Mocktail and fails with the error "
No matching calls. All calls: Listener<AsyncValue<Counter>>.call(null, AsyncError<Counter>(error: Exception: test,...)
".Here are the two tests for comparison:
Test with Mocktail (fails):
Test with Mockito (passes):
CounterQuery and FetchCounter:
This issue seems to be specific to Mocktail, as the test passes with Mockito. I'm not sure if this is an issue with Mocktail itself or some interaction between Mocktail and Riverpod/AsyncValue.
Any help on this issue would be greatly appreciated!