Questions tagged [bloc-test]
31 questions
1
vote
2 answers
Flutter Bloc test "bloc.add" null safety issue
I have a flutter bloc_test which is failing due to recent upgrades in Flutter involving null safety.
I have the following code
blocTest('get the usecase name',
build: () {
when(() => mockGetUseCaseName(any()))
…

MikeSmith
- 299
- 2
- 6
0
votes
0 answers
Test that tests a cubit that calls an emitting method in its constructor fails
What am I doing wrong here?
Error:
Expected: should emit an event that
Actual: '>
Which: emitted • Instance of 'AlbumListData'
Cubit:
class AlbumListCubit…

Mantoska
- 1,349
- 1
- 12
- 28
0
votes
0 answers
How to test api requests in cubit(f.e signIn request)?
I have an authorization cubit and I want to test signIn request, but I can't find out how to do this..
This is my signIn request inside cubit:
class AuthCubit extends Cubit {
AuthCubit() : super(const AuthState(
email: "",
…

newbie2210
- 223
- 8
0
votes
1 answer
Why state is not updating in bloc_test?
I am new at testing of flutter app, so I am trying to find out how to test it correctly, and now I am confused when I faced this error. When I try to change state in bloc_state testing then state doesn't change at all. So how can I fix that?
class…

newbie2210
- 223
- 8
0
votes
1 answer
Flutter [bloc_test] not throwing a expection
When I want to test my completedIntroTutorial method, I'd like to also test the on Exception catch for that I call inside the unit test thenThrow, but it isn't throwing an exception.
I have tried to use the following things in the thenThrow method:…

Tempelritter
- 471
- 9
- 22
0
votes
0 answers
type 'Null' is not a subtype of type 'Future' in Mocktail
I'm trying to test my cubit which have two repositories, SomethingRepository and AnotherRepository.
I'm using mocktail and bloc_test, and I'm having troubles to use two whens inside build parameters of bloc_test, always throwing TypeError.
...
…

Harley Venturini
- 1
- 1
0
votes
0 answers
How can I test a future function using bloc test
I'm new to bloc and currently learning bloc testing. The below code is
working fine in debug mode. However, I can't find anything to await the
function to test the current position/error.
Here is my bloc
class GoogleMapBloc extends…
0
votes
1 answer
Flutter Dartz bloc test argument type not assignable issue
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…

Rohit
- 895
- 1
- 9
- 19
0
votes
0 answers
Why I'm getting empty actual array from blocTest function?
So I'm implementing blocTesting for my project and I'm getting an empty actual array from a specific feature.
share_bloc_test.dart
Below is the code for the blocFunction that is returning the empty actual array.
group('ShareDisconnectGrantor',…

Nik
- 187
- 3
- 17
0
votes
0 answers
Flutter Bloc Test Problem With Comparing Expected and Actual
I'm trying to create a test case for getting list stores data and I currently fail to implement some working tests but I got some problems when trying to compare the data list.
This is my test's code:
blocTest(
"_getListStore - successCase",
…

Nazarudin
- 917
- 8
- 26
0
votes
1 answer
How to test getters in a state class using bloc_test?
Say I have a state class
class MyState extends Equatable {
final bool isSaving;
final String errorMsg;
const MyState({
this.isSaving = false,
this.errorMsg = '',
});
@override
List

chrallard
- 127
- 1
- 7
0
votes
1 answer
Flutter blocTest Missing type arguments for generic function 'blocTest, State>'
When following the bloc test documentation, I created the following blocTest;
blocTest('should do something',
build: () => SignInBloc(signIn: mockSignIn),
act: (bloc) => bloc.add(const OnEmailChanged(email: 'test')));
However I get the…

c.lamont.dev
- 693
- 1
- 6
- 14
0
votes
2 answers
Flutter Bloc Unit Test return an empty array
I'm trying to make a unit test using the bloc_test library.
Here are my codes.
Login Cubit
class LoginCubit extends Cubit with HydratedMixin {
final UserRepository _userRepository;
LoginCubit(this._userRepository) :…

Zouglou
- 89
- 1
- 11
0
votes
1 answer
Flutter blocTest returning empty 'actual' array
So i have a simple Cubit class that looks like this:
It is ment to change the isClosed value based on the scrollValue of the list, so if user scrolls up, some widget is going to close.
const SCROLL_CLOSE_VALUE = 50;
class CloseContainerCubit…

Marcel Iwanicki
- 15
- 3
0
votes
1 answer
Flutter: Unit Testing a Cubit issues
I have been trying to set up unit testing for my cubit but bloc test seems to be having issues. Just trying to check the initial state of the values works just fine with regular test but as soon as I try to the same thing with bloc test it spits out…

DA_cloak
- 21
- 5