From 013dda7bb8ee48d610d7ab2961a0b2ee1f4f98f3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Aug 2022 15:47:45 +0100 Subject: [PATCH] Remove dependency jest-mock-console (#52872) * Update dependency jest-mock-console to v2 * let's remove jest-mock-console Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ashley Harrison --- package.json | 1 - .../features/live/centrifuge/LiveDataStream.test.ts | 7 ++----- public/app/features/live/live.test.ts | 12 +++--------- yarn.lock | 10 ---------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 852aa5346a4..2e28d628d51 100644 --- a/package.json +++ b/package.json @@ -209,7 +209,6 @@ "jest-fail-on-console": "2.4.2", "jest-junit": "14.0.0", "jest-matcher-utils": "28.1.3", - "jest-mock-console": "1.2.3", "lerna": "5.2.0", "lint-staged": "13.0.3", "mini-css-extract-plugin": "2.6.1", diff --git a/public/app/features/live/centrifuge/LiveDataStream.test.ts b/public/app/features/live/centrifuge/LiveDataStream.test.ts index 3e7406a352f..17b73f44e72 100644 --- a/public/app/features/live/centrifuge/LiveDataStream.test.ts +++ b/public/app/features/live/centrifuge/LiveDataStream.test.ts @@ -1,4 +1,3 @@ -import mockConsole, { RestoreConsole } from 'jest-mock-console'; import { mapValues } from 'lodash'; import { Observable, Subject, Subscription, Unsubscribable } from 'rxjs'; @@ -123,14 +122,12 @@ const dummyErrorMessage = 'dummy-error'; describe('LiveDataStream', () => { jest.useFakeTimers(); - let restoreConsole: RestoreConsole | undefined; - beforeEach(() => { - restoreConsole = mockConsole(); + jest.spyOn(console, 'log').mockImplementation(jest.fn); }); afterEach(() => { - restoreConsole?.(); + jest.clearAllMocks(); }); const expectValueCollectionState = ( diff --git a/public/app/features/live/live.test.ts b/public/app/features/live/live.test.ts index e31feeb9715..7c1f6f1cc8c 100644 --- a/public/app/features/live/live.test.ts +++ b/public/app/features/live/live.test.ts @@ -1,4 +1,3 @@ -import mockConsole, { RestoreConsole } from 'jest-mock-console'; import { Subject } from 'rxjs'; import { DataQueryResponse, FieldType, LiveChannelScope } from '@grafana/data'; @@ -9,8 +8,6 @@ import { StreamingResponseDataType } from './data/utils'; import { GrafanaLiveService } from './live'; describe('GrafanaLiveService', () => { - let restoreConsole: RestoreConsole | undefined; - const deps = { backendSrv: {}, centrifugeSrv: { @@ -28,13 +25,8 @@ describe('GrafanaLiveService', () => { }, }; - beforeEach(() => { - jest.clearAllMocks(); - restoreConsole = mockConsole(); - }); - afterEach(() => { - restoreConsole?.(); + jest.clearAllMocks(); }); it('should map response from Centrifuge Service to a streaming data frame', async () => { @@ -129,6 +121,7 @@ describe('GrafanaLiveService', () => { }); it('should return an empty frame if first message was not a full frame', async () => { + jest.spyOn(console, 'warn').mockImplementation(jest.fn); const dummySubject = new Subject(); deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject); @@ -154,5 +147,6 @@ describe('GrafanaLiveService', () => { const frame: StreamingDataFrame = response?.data[0]; expect(frame).toBeInstanceOf(StreamingDataFrame); expect(frame.fields).toEqual([]); + expect(console.warn).toHaveBeenCalled(); }); }); diff --git a/yarn.lock b/yarn.lock index 4fe9cde8475..17379fdff04 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21858,7 +21858,6 @@ __metadata: jest-fail-on-console: 2.4.2 jest-junit: 14.0.0 jest-matcher-utils: 28.1.3 - jest-mock-console: 1.2.3 jquery: 3.6.0 js-yaml: ^4.1.0 json-source-map: 0.6.1 @@ -24723,15 +24722,6 @@ __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:^27.5.1": version: 27.5.1 resolution: "jest-mock@npm:27.5.1"