MissingPluginException when running simple Flutter test
Describe the bug A simple test of;
`test('DistilleryService getDistilleries() should return data', () async {
WidgetsFlutterBinding.ensureInitialized();
Supabase.initialize(
url: supabaseURL,
anonKey: supabaseAnonymousKey,
);
await Supabase.instance.client.from('distilleries').select();
});
` Throws an error of;
***** Supabase init completed Instance of 'Supabase'
MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
dart:async _Completer.completeError
package:shared_preferences/shared_preferences.dart 83:19 SharedPreferences.getInstance
===== asynchronous gap ===========================
dart:async _CustomZone.registerBinaryCallback
package:shared_preferences/shared_preferences.dart 78:13 SharedPreferences.getInstance
package:supabase_flutter/src/local_storage.dart 258:38 SharedPreferencesGotrueAsyncStorage._initialize
package:supabase_flutter/src/local_storage.dart 249:5 new SharedPreferencesGotrueAsyncStorage
package:supabase_flutter/src/supabase.dart 86:27 Supabase.initialize
test/distillery/distillery_service_test.dart 15:16 main.<fn>.<fn>
MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
package:flutter/src/services/platform_channel.dart 320:7 MethodChannel._invokeMethod
===== asynchronous gap ===========================
dart:async _CustomZone.registerBinaryCallback
package:supabase_flutter/src/supabase.dart 111:5 Supabase.initialize
test/distillery/distillery_service_test.dart 15:16 main.<fn>.<fn>
To Reproduce Steps to reproduce the behavior:
- Install the supabase_flutter 2.2.0 package
- Run the test above
Expected behavior Test should execute successfully without error.
Screenshots If applicable, add screenshots to help explain your problem.
Version (please complete the following information): On Linux/macOS
── supabase_flutter 2.2.0 │ ├── supabase 2.0.4 │ │ ├── functions_client 2.0.0 │ │ ├── gotrue 2.3.0 │ │ ├── postgrest 2.1.0 │ │ ├── realtime_client 2.0.0 │ │ ├── storage_client 2.0.0
Hi there,
you can take a look at how we test supabase_flutter here. We pass a MockLocalStorage to mock local storage when testing.