Volodymyr Bobyr
Volodymyr Bobyr

Reputation: 424

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?

Upvotes: 4

Views: 549

Answers (1)

Ray Li
Ray Li

Reputation: 7919

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.

Upvotes: 3

Related Questions