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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 0 deletions

View File

@ -190,6 +190,7 @@
"jest-date-mock": "1.0.8",
"jest-junit": "13.0.0",
"jest-matcher-utils": "27.5.0",
"jest-mock-console": "1.2.3",
"lerna": "^4.0.0",
"lint-staged": "12.3.3",
"mini-css-extract-plugin": "2.5.3",

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 () => {

View File

@ -20258,6 +20258,7 @@ __metadata:
jest-date-mock: 1.0.8
jest-junit: 13.0.0
jest-matcher-utils: 27.5.0
jest-mock-console: 1.2.3
jquery: 3.6.0
json-source-map: 0.6.1
jsurl: ^0.1.5
@ -23143,6 +23144,15 @@ __metadata:
languageName: node
linkType: hard
"jest-mock-console@npm:1.2.3":
version: 1.2.3
resolution: "jest-mock-console@npm:1.2.3"
peerDependencies:
jest: ">= 22.4.2"
checksum: 16f449e309919309b87b6ffb7171ff1feccb628bac97c44aa59594951447833abaaac4957be4258e1c7ce3c54ef6e24cb1e2a7c310f7b8cbc6b598323819dc10
languageName: node
linkType: hard
"jest-mock@npm:^24.0.0, jest-mock@npm:^24.9.0":
version: 24.9.0
resolution: "jest-mock@npm:24.9.0"