I am writing flutter test method using bloc_test and mockito library. I am getting below strange issue while mocking repository API call. It might be a simple fix but I am trying it since last couple of hours :(.
Similar code is present in other public repositories but here its not working.
when(() => mockRepository.getPosts())
.thenAnswer((_) async => Right(postEntityList));
getPosts method structure :
@override
Future<Either<Failure, List<PostEntity>>> getPosts() async {
}
Basic blocTest method code:
group('whenListen', () {
blocTest('verify posts bloc tests',
build: () {
when(() => mockRepository.getPosts())
.thenAnswer((_) async => postEntityList);
return postsBloc;
},
act: (PostsBloc postBloc) {
postBloc.getAllPostsUseCase();
},
expect: () => (isA<PostsInitial>()));
});

You are not using it in the right way.
dartzpackage usesRightorLeftclasses to access the actual type. Simply change thepostEntityListtoRight(postEntityList)