cypress-firebase icon indicating copy to clipboard operation
cypress-firebase copied to clipboard

feat(commands): command for creating a user

Open prescottprue opened this issue 5 years ago • 4 comments

As mentioned in #14 by @fabiocarneiro there is a need for creating user's during tests:

I would like to have it like this:

cy.firebaseSignUp(email, password) cy.firebaseSignIn(email, password) other authentication options would also be interesting

Notes

  • Documentation should clearly specify that password should be stored in the cypress environment only (preferably passed in by CLI flag or passed from the environment running cypress)

Open Questions

  • Which other user auth methods need to be supported?
  • Is this best practice? Running a number of tests will cause the amount of users to build up over time - it is better practice to clean up after completing tests

prescottprue avatar Feb 08 '20 01:02 prescottprue

Although I also think in the direction passwords should not be in the code, I tend to think preventing this is not so much responsibility of the library (warnings are fine). I suggest to focus in two directions:

  • Help the library users to obtain one or multiple account data in a convenient way. Single env variable can be quite cumbersome with large userbase.
  • Allowing accounts to be easily created, either with defined usernames/passwords or with pattern/randomly created credentials.

fabiocarneiro avatar Feb 08 '20 08:02 fabiocarneiro

Something of note: Just using a UID that doesn't already exist creates the user if you are using cy.login since it is generating a custom auth token through firebase-admin which does this automatically.

Does that handle your case @fabiocarneiro? I would like to avoid directly advocating for creating new users in tests since it would require cleanup - this would add tons and tons of new accounts even after of a short time of having tests run as part of a CI flow where builds/tests are run regularly

prescottprue avatar May 02 '20 06:05 prescottprue

@prescottprue for my use case, I'm using the email returned from an authenticated session to do something in my app. I could likely rewrite my app logic to grab the email in another way but having this built into cypress-firebase would be a nice addition.

By the way, thanks for all of your work on cypress-firebase!

btjones avatar Jul 01 '21 01:07 btjones

cy.deleteUser() would be the most usefull because when I test the account creation, I need to manually delete the user in the firebase authentification emulator

damienromito avatar Nov 18 '21 15:11 damienromito