diff --git a/tests/camera-manager/utils/go2rtc-audio.test.ts b/tests/camera-manager/utils/go2rtc-audio.test.ts index 5c8207f1..6748be63 100644 --- a/tests/camera-manager/utils/go2rtc-audio.test.ts +++ b/tests/camera-manager/utils/go2rtc-audio.test.ts @@ -25,7 +25,7 @@ describe('supports2WayAudio', () => { vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue(endpoint); vi.mocked(homeAssistantSignAndFetch).mockRejectedValue(new Error('fetch error')); - const spy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const spy = vi.spyOn(console, 'warn'); const result = await supports2WayAudio(hass, 2, endpoint); expect(result).toBe(false); diff --git a/tests/card-controller/issues/state-manager.test.ts b/tests/card-controller/issues/state-manager.test.ts index 254cc317..8f7b7c6d 100644 --- a/tests/card-controller/issues/state-manager.test.ts +++ b/tests/card-controller/issues/state-manager.test.ts @@ -70,7 +70,7 @@ describe('IssueStateManager', () => { }); it('should isolate a failing issue and continue detecting the rest', async () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); assert(mockConfigUpgrade.detectStatic); assert(mockLegacyResource.detectStatic); assert(mockMediaLoad.detectStatic); @@ -345,7 +345,7 @@ describe('IssueStateManager', () => { describe('logging', () => { it('should log on static detection when issue is active', async () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); const result = createIssueDescription({ notification: { body: { text: 'Legacy issue' } }, }); @@ -362,7 +362,7 @@ describe('IssueStateManager', () => { }); it('should log on dynamic evaluation when issue becomes active', () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); const result = createIssueDescription({ notification: { body: { text: 'Stream issue' } }, }); @@ -379,7 +379,7 @@ describe('IssueStateManager', () => { }); it('should log on trigger when the issue becomes active', () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); const result = createIssueDescription({ notification: { body: { text: 'Triggered' } }, }); @@ -393,7 +393,7 @@ describe('IssueStateManager', () => { }); it('should not log on trigger when the issue stays inactive', () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); vi.mocked(mockMediaLoad.getIssue).mockReturnValue(null); const manager = createManager(); @@ -404,7 +404,7 @@ describe('IssueStateManager', () => { }); it('should not log on trigger for an unknown key', () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); const manager = createManager(); manager.trigger('unknown' as never, {} as never); @@ -414,7 +414,7 @@ describe('IssueStateManager', () => { }); it('should only log once per issue key', async () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); const result = createIssueDescription({ notification: { body: { text: 'Repeated' } }, }); @@ -430,7 +430,7 @@ describe('IssueStateManager', () => { }); it('should not log when issue has no result', async () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); vi.mocked(mockLegacyResource.hasIssue).mockReturnValue(false); const manager = createManager(); @@ -441,7 +441,7 @@ describe('IssueStateManager', () => { }); it('should not log when issue result has no summarizable text', async () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); // Notification has neither body.text nor heading.text const result = createIssueDescription({ notification: {}, @@ -457,7 +457,7 @@ describe('IssueStateManager', () => { }); it('should log again after the issue clears and re-activates', async () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); const first = createIssueDescription({ notification: { body: { text: 'First' } }, }); @@ -490,7 +490,7 @@ describe('IssueStateManager', () => { }); it('should log again after reset and re-activation', () => { - const spy = vi.spyOn(console, 'warn').mockReturnValue(); + const spy = vi.spyOn(console, 'warn'); const description = createIssueDescription({ notification: { body: { text: 'Repeat' } }, }); diff --git a/tests/components-lib/gallery/controller.test.ts b/tests/components-lib/gallery/controller.test.ts index 82a8191e..6165be63 100644 --- a/tests/components-lib/gallery/controller.test.ts +++ b/tests/components-lib/gallery/controller.test.ts @@ -285,7 +285,7 @@ describe('GalleryController', () => { manager.getView.mockReturnValue(view); const error = new Error('test error'); - const spy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const spy = vi.spyOn(console, 'warn'); runner.extend.mockRejectedValue(error); await controller.extend(runner, epoch, 'earlier'); diff --git a/tests/components-lib/media/notification-controller.test.ts b/tests/components-lib/media/notification-controller.test.ts index 04726ebd..3e8e5d3e 100644 --- a/tests/components-lib/media/notification-controller.test.ts +++ b/tests/components-lib/media/notification-controller.test.ts @@ -416,8 +416,6 @@ describe('MediaNotificationController', () => { assert(controls); expect(controls).toHaveLength(4); - vi.spyOn(console, 'warn').mockImplementation(() => {}); - // 1. Review control expect(controls?.[0].tooltip).toBe('Mark as reviewed'); expect(controls?.[0].dismiss).toBe(false); diff --git a/tests/components-lib/signed-url-controller.test.ts b/tests/components-lib/signed-url-controller.test.ts index e21db08d..b0170a46 100644 --- a/tests/components-lib/signed-url-controller.test.ts +++ b/tests/components-lib/signed-url-controller.test.ts @@ -374,8 +374,6 @@ describe('SignedURLController', () => { it('should handle errors gracefully', async () => { const host = mock(); const hass = createHASS(); - const consoleSpy = vi.spyOn(console, 'warn').mockReturnValue(); - vi.mocked(createProxiedEndpointIfNecessary).mockRejectedValue( new Error('test-error'), ); @@ -399,7 +397,6 @@ describe('SignedURLController', () => { expect(controller.getValue()).toBeNull(); expect(controller.getError()).toBe('proxy'); expect(host.requestUpdate).toBeCalledTimes(1); - consoleSpy.mockRestore(); }); it('should not retry after sign error with same inputs', async () => { @@ -437,7 +434,6 @@ describe('SignedURLController', () => { it('should set sign error when signing throws', async () => { const host = mock(); const hass = createHASS(); - const consoleSpy = vi.spyOn(console, 'error').mockReturnValue(undefined); vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue({ endpoint: 'http://proxied-url.com', @@ -462,7 +458,6 @@ describe('SignedURLController', () => { expect(controller.getValue()).toBeNull(); expect(controller.getError()).toBe('sign'); - consoleSpy.mockRestore(); }); it('should not fetch again if within cache TTL', async () => { @@ -652,7 +647,6 @@ describe('SignedURLController', () => { // Pending forever for request 2. new Promise(() => {}), ); - vi.spyOn(console, 'warn').mockImplementation(() => {}); const controller = new SignedURLController(host, () => ({ hass, diff --git a/tests/utils/media-actions.test.ts b/tests/utils/media-actions.test.ts index d354b54f..183b0512 100644 --- a/tests/utils/media-actions.test.ts +++ b/tests/utils/media-actions.test.ts @@ -84,7 +84,7 @@ describe('MediaActions', () => { const error = new Error('fail'); viewItemManager.reviewMedia.mockRejectedValue(error); - const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const consoleSpy = vi.spyOn(console, 'warn'); expect(await toggleReviewed(item, viewItemManager)).toBe(false); expect(consoleSpy).toHaveBeenCalledWith(error.message); @@ -128,7 +128,7 @@ describe('MediaActions', () => { const error = new Error('fail'); viewItemManager.favorite.mockRejectedValue(error); - const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const consoleSpy = vi.spyOn(console, 'warn'); expect(await toggleFavorite(item, viewItemManager)).toBe(false); expect(consoleSpy).toHaveBeenCalledWith(error.message); @@ -158,7 +158,7 @@ describe('MediaActions', () => { const error = new Error('fail'); viewItemManager.download.mockRejectedValue(error); - const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const consoleSpy = vi.spyOn(console, 'warn'); expect(await downloadMedia(item, viewItemManager)).toBe(false); expect(consoleSpy).toHaveBeenCalledWith(error.message); diff --git a/tests/utils/task.test.ts b/tests/utils/task.test.ts index 7939730c..0d078e5b 100644 --- a/tests/utils/task.test.ts +++ b/tests/utils/task.test.ts @@ -46,7 +46,7 @@ describe('task utilities', () => { task.render.mockImplementation((renderers) => renderers.error?.(new Error('test error')), ); - const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + const consoleSpy = vi.spyOn(console, 'warn'); const errorFunc = vi.fn().mockReturnValue(html`error`); const result = renderTask(task, (r) => html`${r}`, { errorFunc }); diff --git a/vite.config.ts b/vite.config.ts index 65b3cc80..5a00461e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -30,6 +30,12 @@ export default defineConfig({ }, }, include: INCLUSIONS, + + // Hide console writing to keep output clean, usual sources of noise: + // - Unnecessary Lit dev-mode warnings. + // - Various console outputs (that are expected/tested). + onConsoleLog: () => false, + coverage: { exclude: EXCLUSIONS,