Skip to content
New issue

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

Testing and mocking guide #864

Open
tomasAlabes opened this issue Mar 20, 2024 · 0 comments
Open

Testing and mocking guide #864

tomasAlabes opened this issue Mar 20, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@tomasAlabes
Copy link

tomasAlabes commented Mar 20, 2024

To keep #109 alive, related to #36, supabase/supabase-dart#12.

Any serious project needs unit testing around components using Supabase.
In my particular case, I have a provider that fetches data with Supabase Postgrest client, I haven't been able to mock the calls to return mock data.

Some references I've seen, but nothing really works:

An example code to be tested:

class EntitiesProvider with ChangeNotifier {
  final supabase = GetIt.instance.get<SupabaseClient>();
  var _entities = <Entity>[];

  UnmodifiableListView<Entity> entities = UnmodifiableListView(_entities);
  
  Future<void> fetchEntities() async {
   // some logic
    _entities = await supabase.from("entities").select().map((e) => Entity.fromJson(e)).toList();
   // some logic
  }

}

I know there are ways to work around this, but I'm looking for a blessed and official way from the Supabase team.

@tomasAlabes tomasAlabes added the enhancement New feature or request label Mar 20, 2024
@dshukertjr dshukertjr added the documentation Improvements or additions to documentation label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants