'How do I initialice Firebase for flutter Widget Testign

Im trying to test if i get an error message whenever i try to login without writing the credentials.

The widget with the message "Entrar" (enter) is a button. After pushing it firebase auth function checks the credentials.

This is my test code:

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:untitled1/login/login_page.dart';
import 'package:untitled1/welcomepage.dart';

Future <void> main() async{  
TestWidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  
  testWidgets('Nos salta un error si no Introducimos las credenciales', (WidgetTester tester) async {
    await tester.pumpWidget(MaterialApp(title: "TestLP",home:LoginPage()));

    await tester.tap(find.widgetWithText(GestureDetector, "Entrar"));
    await tester.pump();

    expect(find.text("Los datos no coinciden con los de ningún usuario"), findsOneWidget);
  });
}

After running I get the following error:

package:flutter/src/services/platform_channel.dart 175:7                                             MethodChannel._invokeMethod
===== asynchronous gap ===========================
package:flutter/src/services/platform_channel.dart 363:35                                            MethodChannel.invokeListMethod
===== asynchronous gap ===========================
package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart 31:23       MethodChannelFirebase._initializeCore
===== asynchronous gap ===========================
package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart 73:7        MethodChannelFirebase.initializeApp
===== asynchronous gap ===========================
package:firebase_core/src/firebase.dart 40:31                                                        Firebase.initializeApp
===== asynchronous gap ===========================
test\test_widgetwp.dart 20:3                                                                         main
===== asynchronous gap ===========================
..\..\..\AppData\Local\Temp\flutter_tools.603228d6\flutter_test_listener.83f7b54\listener.dart 19:3  _testMain

Failed to load "C:\Users\alber\AndroidStudioProjects\Flut_last\P2DS_FLUTTER\test\test_widgetwp.dart": MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source