Skip to content

Commit 527b5bf

Browse files
committed
fix: ensure test isolation in storage tests
- Use unique keys for each test to prevent SharedPreferences state leakage - Fix flaky tests that were failing due to shared state between test runs - Tests now pass consistently in CI/CD environments
1 parent 6c35a37 commit 527b5bf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/supabase_flutter/test/storage_test.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ void main() {
88
group('Storage Tests', () {
99
// SharedPreferencesLocalStorage Tests
1010
group('SharedPreferencesLocalStorage', () {
11-
const persistSessionKey = 'test_persist_key';
1211
const testSessionValue = '{"key": "value"}';
1312

1413
Future<SharedPreferencesLocalStorage> createFreshLocalStorage() async {
14+
// Use a unique key for each test to ensure complete isolation
15+
final uniqueKey = 'test_persist_key_${DateTime.now().microsecondsSinceEpoch}';
16+
1517
// Set up fresh shared preferences for each test
1618
SharedPreferences.setMockInitialValues({});
19+
1720
final localStorage = SharedPreferencesLocalStorage(
18-
persistSessionKey: persistSessionKey,
21+
persistSessionKey: uniqueKey,
1922
);
2023
await localStorage.initialize();
2124
return localStorage;

0 commit comments

Comments
 (0)