We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've tried fixing using MockFirebaseAuth.instance by defining get in MockFirebaseAuth + initializing FirebaseApp with TestWidgetsFlutterBinding.
Problem code posted below...
firebase_flutter_repository_test.dart:
firebase_flutter_repository_test.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_flutter_repository/firebase_user_repository.dart'; import 'package:custom_repository_core/custom_repository_core.dart'; import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; void main() { group('FirebaseUserRepository', () { test('should log the user in anonymously', () async { final auth = MockFirebaseAuth(); final repository = FirebaseUserRepository(auth); when(auth.signInAnonymously()) .thenAnswer((_) => Future.value(MockUserCredential())); final entity = await repository.login(); expect(entity, TypeMatcher<UserEntity>()); }); }); } class MockFirebaseAuth extends Mock implements FirebaseAuth {} class MockFirestore extends Mock implements FirebaseFirestore {} class MockUserCredential extends Mock implements UserCredential {}
firebase_user_repository.dart:
firebase_user_repository.dart
import 'dart:async'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:custom_repository_core/custom_repository_core.dart'; class FirebaseUserRepository implements UserRepository { final FirebaseAuth auth; const FirebaseUserRepository(this.auth); @override Future<UserEntity> login() async { final firebaseUser = await auth.signInAnonymously(); return UserEntity( id: firebaseUser.user.uid, /// firebaseUser.user shows up as null displayName: firebaseUser.user.displayName, ); } }
pubspec.yaml
environment: sdk: '>=2.0.0 <3.0.0' dependencies: flutter: sdk: flutter custom_repository_core: path: ../custom_repository_core firebase_auth: ^1.1.3 cloud_firestore: ^2.0.0 dev_dependencies: test: mockito: flutter_test: sdk: flutter flutter:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I've tried fixing using MockFirebaseAuth.instance by defining get in MockFirebaseAuth + initializing FirebaseApp with TestWidgetsFlutterBinding.
Problem code posted below...
firebase_flutter_repository_test.dart
:firebase_user_repository.dart
:pubspec.yaml
The text was updated successfully, but these errors were encountered: