Closed bizz84 closed 10 months ago
More info on this discussion: https://github.com/firebase/flutterfire/discussions/10581
This was fixed and there's a note about testing on our docs: https://github.com/firebase/FirebaseUI-Flutter/tree/main/docs/firebase-ui-auth#writing-widget-unit-tests
Bug report
Describe the bug
Running the widget test from the sample app attached results in the following exception:
Steps to reproduce
Steps to reproduce the behavior:
flutterfire configure
flutter test
Expected behavior
The test passes.
Observed behavior
The test fails with this exception:
Click To Expand
``` βββ‘ EXCEPTION CAUGHT BY WIDGETS LIBRARY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ The following _Exception was thrown building KeyedSubtree-[GlobalKey#cb6c1]: Exception: You must call Firebase.initializeApp() before calling configureProviders() The relevant error-causing widget was: Scaffold Scaffold:file:///Users/andrea/work/codewithandrea/github/flutter/firebase_ui_auth_widget_tests_bug/lib/main.dart:36:12 When the exception was thrown, this was the stack: #0 FirebaseUIAuth.configureProviders (package:firebase_ui_auth/firebase_ui_auth.dart:115:7) firebase/flutterfire#1 ScreenElement.mount (package:firebase_ui_auth/src/screens/internal/multi_provider_screen.dart:50:24) ... Normal element mounting (25 frames) firebase/flutterfire#26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3953:16) firebase/flutterfire#27 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6512:36) firebase/flutterfire#28 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6524:32) ... Normal element mounting (326 frames) firebase/flutterfire#354 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3953:16) firebase/flutterfire#355 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6512:36) firebase/flutterfire#356 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6524:32) ... Normal element mounting (467 frames) firebase/flutterfire#823 _UncontrolledProviderScopeElement.mount (package:flutter_riverpod/src/framework.dart:309:11) ... Normal element mounting (9 frames) firebase/flutterfire#832 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3953:16) firebase/flutterfire#833 Element.updateChild (package:flutter/src/widgets/framework.dart:3676:20) firebase/flutterfire#834 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1176:16) firebase/flutterfire#835 RenderObjectToWidgetElement.update (package:flutter/src/widgets/binding.dart:1153:5) firebase/flutterfire#836 RenderObjectToWidgetElement.performRebuild (package:flutter/src/widgets/binding.dart:1167:7) firebase/flutterfire#837 Element.rebuild (package:flutter/src/widgets/framework.dart:4690:5) firebase/flutterfire#838 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2743:19) firebase/flutterfire#839 AutomatedTestWidgetsFlutterBinding.drawFrame (package:flutter_test/src/binding.dart:1336:19) firebase/flutterfire#840 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5) firebase/flutterfire#841 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15) firebase/flutterfire#842 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1218:9) firebase/flutterfire#843 AutomatedTestWidgetsFlutterBinding.pump.Sample project
Link: https://github.com/bizz84/firebase_ui_auth_widget_tests_bug
Additional context
Tested with the following packages:
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [β] Flutter (Channel stable, 3.7.0, on macOS 13.2 22D49 darwin-x64, locale en-GB) [β] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [β] Xcode - develop for iOS and macOS (Xcode 14.2) [β] Chrome - develop for the web [β] Android Studio (version 4.2) [β] VS Code (version 1.76.0) [β] Connected device (4 available) [β] HTTP Host Availability β’ No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Dart SDK 2.19.0 Flutter SDK 3.7.0 firebase_ui_auth_widget_tests_bug 1.0.0+1 dependencies: - cupertino_icons 1.0.5 - firebase_auth 4.2.10 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.7.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_ui_auth 1.1.16 [email_validator firebase_auth firebase_core firebase_dynamic_links firebase_ui_localizations firebase_ui_oauth flutter flutter_localizations flutter_svg] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_riverpod 2.3.1 [collection flutter meta riverpod state_notifier] dev dependencies: - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - mocktail 0.3.0 [collection matcher test] transitive dependencies: - _fe_analyzer_shared 55.0.0 [meta] - _flutterfire_internals 1.0.17 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 5.7.1 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.4.0 - async 2.10.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - characters 1.2.1 - clock 1.1.1 - collection 1.17.0 - convert 3.1.1 [typed_data] - coverage 1.6.3 [args logging package_config path source_maps stack_trace vm_service] - crypto 3.0.2 [typed_data] - desktop_webview_auth 0.0.11 [crypto flutter http flutter_web_plugins plugin_platform_interface] - email_validator 2.1.17 - fake_async 1.3.1 [clock collection] - file 6.1.4 [meta path] - firebase_auth_platform_interface 6.11.12 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.2.9 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.5.3 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.2.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_dynamic_links 5.0.16 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.3+31 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_ui_localizations 1.2.0 [flutter flutter_localizations intl path] - firebase_ui_oauth 1.1.16 [desktop_webview_auth firebase_auth firebase_ui_auth flutter_svg flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - glob 2.1.1 [async collection file path string_scanner] - http 0.13.5 [async http_parser meta path] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - intl 0.17.0 [clock path] - io 1.0.4 [meta path string_scanner] - js 0.6.5 [meta] - lints 2.0.1 - logging 1.1.1 - matcher 0.12.13 [meta stack_trace] - material_color_utilities 0.2.0 - meta 1.8.0 - mime 1.0.4 - node_preamble 2.0.2 - package_config 2.1.0 [path] - path 1.8.2 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - petitparser 5.1.0 [meta] - plugin_platform_interface 2.1.4 [meta] - pool 1.5.1 [async stack_trace] - pub_semver 2.1.3 [collection meta] - riverpod 2.3.1 [collection meta stack_trace state_notifier] - shelf 1.4.0 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 3.0.1 [path shelf shelf_static] - shelf_static 1.1.1 [convert http_parser mime path shelf] - shelf_web_socket 1.0.3 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_map_stack_trace 2.1.1 [path source_maps stack_trace] - source_maps 0.10.12 [source_span] - source_span 1.9.1 [collection path term_glyph] - stack_trace 1.11.0 [path] - state_notifier 0.7.2+1 [meta] - stream_channel 2.1.1 [async] - string_scanner 1.2.0 [source_span] - term_glyph 1.2.1 - test 1.22.0 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] - test_api 0.4.16 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - test_core 0.4.20 [analyzer async args boolean_selector collection coverage frontend_server_client glob io meta package_config path pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - typed_data 1.3.1 [collection] - vector_math 2.1.4 - vm_service 9.4.0 - watcher 1.0.2 [async path] - web_socket_channel 2.3.0 [async crypto stream_channel] - webkit_inspection_protocol 1.2.0 [logging] - xml 6.2.2 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```