Skip to content

test(supabase_flutter): silence debug logs during tests - #1529

Closed
spydon wants to merge 2 commits into
mainfrom
chore/silence-supabase-flutter-test-logs
Closed

test(supabase_flutter): silence debug logs during tests#1529
spydon wants to merge 2 commits into
mainfrom
chore/silence-supabase-flutter-test-logs

Conversation

@spydon

@spydon spydon commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Silences the INFO/CONFIG log noise that supabase_flutter tests emit while passing.

Why

Supabase.initialize sets _debugEnable = debug ?? kDebugMode. Under flutter test, kDebugMode is true, so any test that doesn't pass debug: false attaches the log subscription and spams the console with lines like ***** Supabase init completed *****. Most tests here already pass debug: false; a handful were missing it.

Keeping the test output clean also matters for the upcoming flutter/tests registry entry (#1528), which expects tests to have no output when passing.

Changes

  • Add debug: false to the Supabase.initialize calls that omitted it in initialization_test.dart, widget_test.dart, and dispose_test.dart.
  • For the two tests in initialization_test.dart that intentionally use debug: true (the only coverage of the log-subscription path), override debugPrint to a no-op in setUpAll so the path is still exercised but nothing prints.

Verification

flutter test in packages/supabase_flutter: all 57 tests pass with no stray log output.

@spydon
spydon requested a review from a team as a code owner July 3, 2026 14:59
@spydon spydon closed this Jul 3, 2026
spydon added a commit that referenced this pull request Jul 6, 2026
…1530)

## What

Makes `Supabase.initialize`'s `debug` option default to `false` when
running under `flutter test`, so tests no longer emit `INFO`/`CONFIG`
log noise unless they explicitly opt in with `debug: true`.

## Why

`debug` defaults to `debug ?? kDebugMode`. Under `flutter test`,
`kDebugMode` is `true`, so every test that doesn't pass `debug: false`
attaches the log subscription and spams the console (`***** Supabase
init completed *****`, etc.). Rather than sprinkling `debug: false`
across every test, this fixes the default at the source.

This is the more general fix behind #1529 (which added `debug: false`
per call). With this change those manual additions are no longer needed,
so **#1529 can be closed in favor of this**.

## How

Reuses the existing web-safe `isRunningInFlutterTest` getter (already
used in `supabase_auth.dart`, defined via the `platform_stub.dart` /
`platform_io.dart` conditional import, which reads the `FLUTTER_TEST`
env var):

```dart
_instance._debugEnable = debug ?? (kDebugMode && !isRunningInFlutterTest);
```

Production behavior is unchanged: `isRunningInFlutterTest` is `false`
outside tests (and the web stub returns `false`), so the expression
reduces to the previous `debug ?? kDebugMode`.

## Verification

- New `test/debug_default_test.dart` asserts the default is off under
`flutter test` and that explicit `debug: true` still logs.
- Full `packages/supabase_flutter` suite: all 59 tests pass with no
stray supabase log output; `flutter analyze --no-fatal-infos` is clean.
@spydon
spydon deleted the chore/silence-supabase-flutter-test-logs branch July 7, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant