title: How to mock firebase.auth.UserCredential jest?
body: <p>This is my current mock i want <code>createUserWithEmailAndPassword</code> to return <code>firebase.auth.UserCredential</code> so i can test if it is being called or not in my <code>App.ts</code></p>
  
  <p><strong>App.spec.ts</strong></p>
  
  <pre><code>import myAuthenticationPlugin from 'authenticationPlugin/App'
  import firebase from 'firebase/app'
  jest.mock('firebase/app', () =&gt; {
    return {
      auth: jest.fn().mockReturnThis(),
      currentUser: {
        email: 'test',
        uid: '123',
        emailVerified: true
      },
  
      signInWithEmailAndPassword: jest.fn(),
      createUserWithEmailAndPassword:jest.fn(() =&gt; {
        return {
          user:{
            sendEmailVerification:jest.fn(),
          },
        }
      }),
      initializeApp:jest.fn()
    };
  });
  
   describe('Test for signup (email,password)',() =&gt; {
  
      it('createUserWithEmailAndPassword ()',async () =&gt; {  //this works
        await myAuthenticationPlugin.signup(email, password)
        expect(firebase.auth().createUserWithEmailAndPassword).toBeCalledWith(email, password)
      })
  
      it('sendEmailVerification()',async ()=&gt;{
        await myAuthenticationPlugin.signup(email, password)
        const userCredential= await firebase.auth().createUserWithEmailAndPassword(email,password)
        if(userCredential.user!=null){
        expect(userCredential.user.sendEmailVerification).toBeCalled() //this fails as i'm not able to mock properly
        }
      })
    })
  </code></pre>
  
  <p><strong>App.ts</strong></p>
  
  <pre><code>import firebase from 'firebase/app'
  import 'firebase/auth'
  import './Init'
  const App= {
   signup: async (email, password) =&gt; {
      const userCredential = await firebase.auth().createUserWithEmailAndPassword(email, password)
      await userCredential.user.sendEmailVerification()
      return `Check your email for verification mail before logging in`
    },
  }
  export default App
  </code></pre>