From 378ce15418bff525f5393797c0a97653a4e4729c Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 11 Feb 2022 14:56:25 +0000 Subject: [PATCH] Stub console.warn (#45311) --- .../transports/CustomEndpointTransport.test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts b/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts index 96df2dd01c8..16f6e484f4e 100644 --- a/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts +++ b/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts @@ -3,7 +3,18 @@ import { CustomEndpointTransport } from './CustomEndpointTransport'; describe('CustomEndpointTransport', () => { const fetchSpy = (window.fetch = jest.fn()); - beforeEach(() => jest.resetAllMocks()); + let consoleSpy: jest.SpyInstance; + + beforeEach(() => { + jest.resetAllMocks(); + // The code logs a warning to console + // Let's stub this out so we don't pollute the test output + consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => {}); + }); + + afterEach(() => { + consoleSpy.mockRestore(); + }); const now = new Date(); const event: Event = { @@ -87,7 +98,7 @@ describe('CustomEndpointTransport', () => { expect(fetchSpy).toHaveBeenCalledTimes(2); }); - it('will drop events if max concurrency is reached', async () => { + it('will drop events and log a warning to console if max concurrency is reached', async () => { const calls: Array<(value: unknown) => void> = []; fetchSpy.mockImplementation( () =>