Closed p12y closed 5 years ago
In my component I have an observer listening for auth state change:
firebase.auth().onAuthStateChanged(async (user) => { // Set user state });
In my test, I am changing the auth state like so:
const wrapper = mount(<Root />); mockFirebase.auth().changeAuthState({ uid: 'testUid', provider: 'email', token: 'authToken', expires: Math.floor(new Date() / 1000) + 24 * 60 * 60, auth: { isAdmin: true } }); mockFirebase.auth().flush(); wrapper.update();
The problem is that changing the auth state in my test is not triggering the observer, meaning the state doesn't get updated in the component during the test.
Is this a bug, or am I misunderstanding the implementation of this? Thanks.
Closing this as it was a mistake in my implementation.
@p12y Do you have an updated sample of how you're doing this? I have the same example code you described above.
How are you making this work now?
In my component I have an observer listening for auth state change:
In my test, I am changing the auth state like so:
The problem is that changing the auth state in my test is not triggering the observer, meaning the state doesn't get updated in the component during the test.
Is this a bug, or am I misunderstanding the implementation of this? Thanks.