test: Silence superfluous console output during test runs (#2540)

This commit is contained in:
Dermot Duffy
2026-06-30 17:45:13 -07:00
committed by dermotduffy
parent 921d45e577
commit fcef48e75a
8 changed files with 23 additions and 25 deletions
@@ -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');
@@ -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);
@@ -374,8 +374,6 @@ describe('SignedURLController', () => {
it('should handle errors gracefully', async () => {
const host = mock<ReactiveControllerHost>();
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<ReactiveControllerHost>();
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,