Firebase Flutter unit testing Firebase.initializeApp()

252 views Asked by At

It's my first time testing an app I tried to test firebase auth and had this error I also search in the doc but everything is outdated or doesn't implement firebase

enter image description here

This is my code

import 'package:ecommerce/main.dart';
import 'package:ecommerce/services/auth.dart';
import 'package:fake_cloud_firestore/fake_cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:rxdart/subjects.dart';

class MockFirebaseAuth extends Mock implements FirebaseAuth {}

class MockFirebaseUser extends Mock implements User {}

class MockUserCredential extends Mock implements Future<UserCredential> {}

void main() {
  MockFirebaseAuth _auth = MockFirebaseAuth();
  MockUserCredential mockUserCredential = MockUserCredential();
  AuthService authManager = AuthService();

  final instance = FakeFirebaseFirestore();

  group("User Auth Test", () {
    test('Returns no user if not signed in', () async {
      final auth = MockFirebaseAuth();
      final user = auth.currentUser;
      expect(user, isNull);
    });
  });
}
0

There are 0 answers