I'm working on a POC with React, Redux and Firebase. I'm currently looking at how to test action creators. I've followed this - https://redux.js.org/recipes/writing-tests#async-action-creators guide and it's been helpful so far. However, as a simple example I want to test that an action is dispatched after successfully authenticating with Firebase like so -
Action creator
export const authenticate = (username, password) => {
return dispatch => {
firebase.auth().signInWithEmailAndPassword(username, password)
.then(() => {
dispatch(authenticationSuccessful())
})
.catch(() => {
});
}
};
Action
const authenticationSuccessful = () => {
return {
type: actionTypes.AUTHENTICATION_SUCCESSFUL
};
};
For the testing side of things I have jest, redux-mock-store and expect. I've researched as to what other people are using for this scenario and I haven't found a definitive answer, I've also looked at https://www.npmjs.com/package/firebase-mock but I don't know if this is a popular choice within the community.
Really appreciate any help in advance!