Support for running unit tests with the Firebase emulators #10648
Replies: 3 comments
-
|
Update: |
Beta Was this translation helpful? Give feedback.
-
|
Are there any plans to support this feature or something that allows unit testing Firebase code? |
Beta Was this translation helpful? Give feedback.
-
|
I have been able to do this with integration tests and using a chrome device. But it does slow down the tests as the chrome device needs to be launched each time a test is run. I also have functions in JS that I can run against the emulator without the same issue but dart/flutter must run on a device to connect to the emulator. I haven't found a way around this yet. There is a package that fakes firestore for dart -> 'package:fake_cloud_firestore/fake_cloud_firestore.dart'; This is good for unit tests but I want a backend function to fill the database and a dart client to update that data which requires the emulator. like the original poster I dont need to test screens just the services the screens call. Has anyone solved this issue? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to use the Firebase emulators as backends for my unit tests.
I would like to start doing test driven development and I have a complex "reactive" system with firebase-functions and firebase-firestore on the back end.
Some logical blocks of my mobile App connect and react to firebase and part of their logic is intertwined with the back end. Because of this, I would like to assume that the backend works.
When writing my Flutter apps unit tests, while I could use Fakes/Mocks for Firebase (suggested approach for unit testing), I think it would be more convenient to load the mock data into the emulators and then test the local logic (in connection with the reactions in the back). I wouldn't say it's a full integration test, because I don't want to test the UI layer (eg. taps). And running integration tests is very slow because it requires running on the device.
Because FlutterFire needs to run on an actual device (eg. Firebase.initializeApp), I'm not able to connect FlutterFire to a local emulator. I think being able to do this could significantly increase my development time.
Is there any way that this can be accomplished? Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions