jeudi 12 novembre 2020

Jest and FirebaseUI

Im trying to implement testing using jest and testing-library/vue. I have been trying to test my Login component which utilizes FirebaseUI, however I continue to get

  The current environment does not support the specified persistence type.

I have tried and tried to set the persistence as shown in this issue on firebaseUI. https://github.com/firebase/firebaseui-web/issues/636 , but no matter what i do it doesn't allow me to setPersistence to None, or it doesn't respect that when the tests are running. I have tried setting the persistence to just none, and it still fails in test. The below code shows this setup. console.log shows true as the output when running tests.

Anyone have any idea? Im unsure if its some kind of race condition or something similar but have no idea how to make it work.

 mounted() {
    //Get the auto generated, standard login form from Firebase
    const redirect = this.$route.params.redirect || '/'
    console.log(process.env.NODE_ENV === 'test')
    fb.firebase
      .auth()
      .setPersistence(
        process.env.NODE_ENV === 'test'
          ? fb.firebase.auth.Auth.Persistence.NONE
          : fb.firebase.auth.Auth.Persistence.NONE
      )
      .then(() => {
        const uiConfig = new fb.firebaseui.auth.AuthUI(fb.auth)
        uiConfig.start('#firebaseui-auth-container', {
          signInSuccessUrl: redirect,
          signInOptions: [
            fb.firebase.auth.GoogleAuthProvider.PROVIDER_ID,
            fb.firebase.auth.FacebookAuthProvider.PROVIDER_ID,
          ],
        })
      })
  },
test.only('It shows the firebaseUI onload', async () => {
  const { findByText } = render(Login, { routes })
  await waitFor(() => {
    expect(findByText('Sign in with Googlesss')).toBeInTheDocument()
  })
})

Aucun commentaire:

Enregistrer un commentaire