Search code examples
firebasereact-nativefirebase-authenticatione2e-testingdetox

Using firebase email link login for e2e tests?


I stumbled upon following issue today while doing automated e2e tests on CI. My app uses 3 firebase login methods: email link, firebase and google.

During e2e tests I initially thought I'll use email link to log in, but this is not possible as app needs to go out into an email client and click on such link, so now I am blocked.

I was researching the docs to see if there was any e2e testing advice on this matter, but wasn't able to find a solution.

Is there a common solution to this provided by firebase? Or is the only way here to use email + password auth?


Solution

  • I think the best practice here would be to split the process in your tests.

    Test 1 would be, let's see if an e-mail was sent as a result of something happening in your detox test. So you click the button and do an API call to your server to see if it has send out an E-Mail. Or you configure your backend to deliver the E-Mail to something that you can query for the email, like Mailtrap or something similar.

    Test 2 would be to see if your app can handle when someone opens that URL. To test this you need to fake such a URL in your backend and open it with detox. For this, you can use the device.relaunchApp, see the detox docs here.