Chore: Clean up logs and warnings from Edge unit tests (#45050)

* #45026: mock console log output in tests

* #45026: update yarn.lock file
This commit is contained in:
Artur Wierzbicki
2022-02-08 20:45:20 +04:00
committed by GitHub
parent d8795d8a32
commit 424a79273f
4 changed files with 30 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import { mapValues } from 'lodash';
import { StreamingFrameAction } from '@grafana/runtime';
import { isStreamingResponseData, StreamingResponseData, StreamingResponseDataType } from '../data/utils';
import { StreamingDataFrame } from '../data/StreamingDataFrame';
import mockConsole, { RestoreConsole } from 'jest-mock-console';
type SubjectsInsteadOfObservables<T> = {
[key in keyof T]: T[key] extends Observable<infer U> ? Subject<U> : T[key];
@@ -119,6 +120,16 @@ const dummyErrorMessage = 'dummy-error';
describe('LiveDataStream', () => {
jest.useFakeTimers();
let restoreConsole: RestoreConsole | undefined;
beforeEach(() => {
restoreConsole = mockConsole();
});
afterEach(() => {
restoreConsole?.();
});
const expectValueCollectionState = <T>(
valuesCollection: ValuesCollection<T>,
state: { errors: number; values: number; complete: boolean }

View File

@@ -4,8 +4,11 @@ import { Subject } from 'rxjs';
import { DataQueryResponse, FieldType, LiveChannelScope } from '@grafana/data';
import { StreamingDataFrame } from './data/StreamingDataFrame';
import { StreamingResponseDataType } from './data/utils';
import mockConsole, { RestoreConsole } from 'jest-mock-console';
describe('GrafanaLiveService', () => {
let restoreConsole: RestoreConsole | undefined;
const deps = {
backendSrv: {},
centrifugeSrv: {
@@ -25,6 +28,11 @@ describe('GrafanaLiveService', () => {
beforeEach(() => {
jest.clearAllMocks();
restoreConsole = mockConsole();
});
afterEach(() => {
restoreConsole?.();
});
it('should map response from Centrifuge Service to a streaming data frame', async () => {