Skip to content

Difficult to mock Supabase auth #36

Open
@seenickcode

Description

@seenickcode

Feature request

Is your feature request related to a problem? Please describe.

Most Flutter apps use only supabase provider auth (i.e. google, in my case). When I want to integration test my app, sadly Flutter cannot interact with web views. Therefore, I am forced to simulate a supabase user session.

What I am doing now is: 1) mocking Supabase when I perform queries and 2) mock Supabase login. The former is pretty straightforward, as I mock a "repository" that wraps interaction with Supabase queries. But my question to the team is that for the latter, it seems messy, with this library, to mock Supabase auth because it seems that if I want to implement my own mock method overrides for SupabaseAuthState, such as onAuthenticated, etc, I have to inject a mock "State" widget into my app.

Describe the solution you'd like

A cleaner way to listen to Supabase auth events. Maybe with a Stream or expose some observer? Overall, it seems that assuming the user will want to override Supabase auth events in the state widget may be too confining and not testing friendly.

I propose that either some integration testing examples are developed in the existing examples provided for supabase_flutter or we discuss some options.

Describe alternatives you've considered

Here's an example of what I am doing now re integration tests and having to inject a mock State widget that extends SupabaseAuthState.

Metadata

Metadata

Assignees

No one assigned

    Labels

    authThis issue or pull request is related to authenticationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions