From 724b00d3d5ec9f5a6b5e5ead3567f82d18447c24 Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Wed, 3 Jun 2026 11:45:13 +0300 Subject: [PATCH] test(layoutStore): silence expected warn in invalid-JSON case The "defaults to list mode when localStorage has invalid data" test feeds invalid JSON on purpose; createPersistentStore logs and swallows the parse error, so its warning (with stack) was polluting CI output. Spy on console.warn to silence it and assert it fired, matching the equivalent test in createPersistentStore.test.ts. --- .../SampleList/model/stores/layoutStore/layoutStore.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/SampleList/model/stores/layoutStore/layoutStore.test.ts b/src/widgets/SampleList/model/stores/layoutStore/layoutStore.test.ts index 8b7bcc0..b96ea16 100644 --- a/src/widgets/SampleList/model/stores/layoutStore/layoutStore.test.ts +++ b/src/widgets/SampleList/model/stores/layoutStore/layoutStore.test.ts @@ -7,6 +7,7 @@ import { describe, expect, it, + vi, } from 'vitest'; // Helper to flush Svelte effects (they run in microtasks) @@ -69,12 +70,17 @@ describe('layoutStore', () => { }); it('should default to list mode when localStorage has invalid data', async () => { + // createPersistentStore logs and swallows the parse error; silence + // the expected warn so it doesn't pollute test output, and assert it. + const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); localStorage.setItem(STORAGE_KEY, 'invalid json'); const { LayoutManager } = await import('./layoutStore.svelte'); const manager = new LayoutManager(); expect(manager.mode).toBe('list'); + expect(warnSpy).toHaveBeenCalled(); + warnSpy.mockRestore(); }); it('should default to list mode when localStorage has empty object', async () => {