Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting Firestore emulator to flutter_test

I'm setting up integration tests for a Flutter app and having trouble connecting them to an instance of a Firestore emulator.

Here's my code:

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  TestWidgetsFlutterBinding.ensureInitialized();
  Firestore firestore;

  setUp(() async {
    firestore = Firestore.instance;
    await firestore.settings(host: 'http://localhost:4000/firestore');
  });

  group('some group', () {
    test('some test', () async {
      print('yo');
    });
  });
}

When I run it, I get the following error:

ERROR: MissingPluginException(No implementation found for method Firestore#settings on channel plugins.flutter.io/cloud_firestore)
package:flutter/src/services/platform_channel.dart 154:7  MethodChannel._invokeMethod

Any suggestions on how to address this?

like image 478
Volodymyr Bobyr Avatar asked Oct 25 '25 10:10

Volodymyr Bobyr


1 Answers

As far as I know, Firebase does not support unit tests in Flutter because it is a plugin that requires native integration.

The tests in the Flutter Firebase repo are run in main.dart, not unit tests.

like image 183
Ray Li Avatar answered Oct 28 '25 01:10

Ray Li