-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 [cloud_firestore] Need working example for Firestore Emulator in Widget tests - initializeApp hangs indefinitely #16727
Comments
Hi @normidar, thanks for raising this concern. However, I don't think this is the right way to go about it. Can you try something like this to see if it resolves your issue: void main() {
setUpAll(() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: 'fake-api-key',
appId: 'fake-app-id',
messagingSenderId: 'fake-sender-id',
projectId: 'demo-project',
),
);
FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8085);
});
testWidgets('some firestore test', (WidgetTester tester) async {
// Test logic here, Firebase is already initialized
});
} |
Thank you for your response. Is it okay to use dummy values like 'fake-api-key' in the test environment, or do I need to use real Firebase credentials? |
I ran that and got an error:
|
You'll have to use your real Firebase credentials. Did you start your firebase emulator before running the test? |
@normidar - we have firestore test setup in the repository that you can follow. https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/example/integration_test/e2e_test.dart Pay attention to test_driver/ and integration_test directory setup. Here is how to run: https://github.com/firebase/flutterfire/blob/main/.github/workflows/android.yaml#L90 As @SelaseKay mentioned - run firebase emualtors. |
Hey @normidar. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @normidar if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
What feature would you like to see?
Issue Description
When trying to use the Firestore Emulator in Widget tests (
testWidgets
),Firebase.initializeApp()
hangs indefinitely. We need a working example of how to properly set up and use the Firestore Emulator in Widget tests.Current Code
Why This Matters
Fake Firestore don't support all Firestore features. Having the ability to test with the actual Firestore Emulator would allow us to:
What I'm Looking For
Environment
The text was updated successfully, but these errors were encountered: