From 10a9ca0ae1c7114a4677291cb492515cf6227387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Tue, 15 Feb 2022 10:12:26 +0100 Subject: [PATCH] Chore: Removes console outputs from runRequest.test.ts (#45375) --- .../features/query/state/runRequest.test.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/public/app/features/query/state/runRequest.test.ts b/public/app/features/query/state/runRequest.test.ts index 981ee3e5113..6742d37d0bf 100644 --- a/public/app/features/query/state/runRequest.test.ts +++ b/public/app/features/query/state/runRequest.test.ts @@ -3,10 +3,10 @@ import { DataQueryRequest, DataQueryResponse, DataSourceApi, + DataTopic, dateTime, LoadingState, PanelData, - DataTopic, } from '@grafana/data'; import { Observable, Subscriber, Subscription } from 'rxjs'; import { runRequest } from './runRequest'; @@ -109,6 +109,26 @@ function runRequestScenario(desc: string, fn: (ctx: ScenarioCtx) => void) { }); } +function runRequestScenarioThatThrows(desc: string, fn: (ctx: ScenarioCtx) => void) { + describe(desc, () => { + const ctx = new ScenarioCtx(); + let consoleSpy: jest.SpyInstance; + + beforeEach(() => { + consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + setEchoSrv(new Echo()); + ctx.reset(); + return ctx.setupFn(); + }); + + afterEach(() => { + consoleSpy.mockRestore(); + }); + + fn(ctx); + }); +} + describe('runRequest', () => { runRequestScenario('with no queries', (ctx) => { ctx.setup(() => { @@ -197,7 +217,7 @@ describe('runRequest', () => { }); }); - runRequestScenario('on thrown error', (ctx) => { + runRequestScenarioThatThrows('on thrown error', (ctx) => { ctx.setup(() => { ctx.error = new Error('Ohh no'); ctx.start();