test(supabase_flutter): silence debug logs during tests - #1529
Closed
spydon wants to merge 2 commits into
Closed
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Silences the
INFO/CONFIGlog noise thatsupabase_fluttertests emit while passing.Why
Supabase.initializesets_debugEnable = debug ?? kDebugMode. Underflutter test,kDebugModeistrue, so any test that doesn't passdebug: falseattaches the log subscription and spams the console with lines like***** Supabase init completed *****. Most tests here already passdebug: 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
debug: falseto theSupabase.initializecalls that omitted it ininitialization_test.dart,widget_test.dart, anddispose_test.dart.initialization_test.dartthat intentionally usedebug: true(the only coverage of the log-subscription path), overridedebugPrintto a no-op insetUpAllso the path is still exercised but nothing prints.Verification
flutter testinpackages/supabase_flutter: all 57 tests pass with no stray log output.