Firebase auth Jest testing

Viewed 572

I wanted to add firebase authentication in an application, and right now I was writing a jest test to see if it was working:

import { login } from "../renderer/Components/Login/LoginService";
import firebase from "firebase";
import initFirebase from "../renderer/Components/FirebaseInit";


//Init Firebase
initFirebase();

test('login-test', () => {
    //Create a user with some credentials
    //If the user already exists, an erorr will be thrown
    firebase.auth().createUserWithEmailAndPassword("example@domain.com", "12345")
        .then((user: firebase.auth.UserCredential) => {
            //Try authenticating with the created user
            firebase.auth().signInWithEmailAndPassword("example@domain.com","12345")
                .then((signedInUser: firebase.auth.UserCredential)=>{
                    let userInfo = signedInUser.user;
                    if(userInfo != null){
                        expect(userInfo.email).toEqual("example@domain.com");
                    }
                })
        })
}
) 

The test says it passed, but when I looked in the firebase console, no new user has been added. Is this the expected behavior(like somehow firebase detected a test and automatically deleted the user when the test finished)

0 Answers
Related