Search code examples
flutterfirebasecontinuous-integrationfirebase-test-labflutter-integration-test

Can/should Firebase TestLab be used to run our integration test suite that relies on the Firebase Emulators and and a script that populates them?


We have been working on an integration test suite for our Flutter project. We are able to run it locally on the Android and iOS simulators, and on chrome for our web version of the app. Now, we would like to run our integration test suite as part of our CI pipeline on GitLab.

Because we don't want our integration tests to interact with a live Firebase project, we are using the Firebase Emulators. We have a bash script that spins up the emulators and populates the Firestore emulator with data and Auth emulator with testing accounts (by running a typescript/javascript script).

However, I cannot find any documentation on how to (or if is even possible to) run the emulators and populate them with test data on Firebase Test Lab.

Zooming out, is it even advisable to use Test Lab to run your integration test suites? I would love some advise from someone who has worked on DevOps for a professional flutter project!

I have looked at the following pages but couldn't find an answer to my question: https://firebase.google.com/docs/test-lab/android/instrumentation-test https://firebase.google.com/docs/test-lab/android/continuous Also it is difficult to find good answers through google or stack overflow because Test Lab calls their virtual devices emulators too, yielding results about those emulators instead of the Firebase Emulators..

Some of the Google / Stack overflow searches that I tried:

  • "firebase emulators" "test lab" site:stackoverflow.com
  • flutter "firestore" "test lab"
  • firebase test lab run custom script

Solution

  • is it even advisable to use Test Lab to run your integration test suites?

    I'd say yes – it's one of the most mature device lab platforms. It has good docs and is quite widely used. You just have to be aware of its limitations – one of which you've just hit :)

    I cannot find any documentation on how to (or if is even possible to) run the emulators and populate them with test data on Firebase Test Lab.

    It's not possible – you can't run any script before or after your tests end. You don't have any kind of shell access that'd allow you to run the Firebase Emulators.

    PS I think you could try hacking around to make it work – for example by running Firebase Emulators on e.g GitHub Actions, exposing them to the internet, and then running tests on Test Lab (with API URLs in your app changed to the Firebase Emulators). But I doubt it's worth it – why not just create a second firebase project to use as "staging/test" environment?