supabase-flutter icon indicating copy to clipboard operation
supabase-flutter copied to clipboard

MissingPluginException when running simple Flutter test

Open paulkeogh opened this issue 2 years ago • 1 comments

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:

  1. Install the supabase_flutter 2.2.0 package
  2. 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

paulkeogh avatar Jan 15 '24 20:01 paulkeogh

Hi there,

you can take a look at how we test supabase_flutter here. We pass a MockLocalStorage to mock local storage when testing.

dshukertjr avatar Jan 16 '24 00:01 dshukertjr