From ce447c91c084432134c98f595614dc1832558f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Mon, 20 Sep 2021 14:45:03 +0000 Subject: [PATCH] test: add work-around to jest@27 isolateModules --- test/unit/progress-logger.test.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/test/unit/progress-logger.test.ts b/test/unit/progress-logger.test.ts index c0efcf3a..afcb634c 100644 --- a/test/unit/progress-logger.test.ts +++ b/test/unit/progress-logger.test.ts @@ -1,4 +1,4 @@ -import ActualProgressLogger from '@progress-logger'; +import ProgressLogger from '@progress-logger'; import { LogMessage } from '@progress-logger/types'; import { mockConfigValue, restoreMockConfig } from '__mocks__/@config'; import { getLastCallArguments } from '../utils'; @@ -6,14 +6,31 @@ import { getLastCallArguments } from '../utils'; jest.unmock('@progress-logger'); describe('progress-logger', () => { - let ProgressLogger: typeof ActualProgressLogger; + // TODO: Use once isolateModules works with jest@27 + // let ProgressLogger: typeof ActualProgressLogger; beforeEach(() => { restoreMockConfig(); - jest.isolateModules(() => { - ProgressLogger = require('../../lib/progress-logger').default; - }); + // TODO: Use once isolateModules works with jest@27 + // jest.isolateModules(() => { + // ProgressLogger = require('../../lib/progress-logger').default; + // }); + }); + + afterEach(() => { + // TODO Remove once isolateModules works with jest@27 + (ProgressLogger as any).messages = []; + (ProgressLogger as any).tasks = []; + (ProgressLogger as any).scannedRepositories = 0; + (ProgressLogger as any).errorCount = 0; + (ProgressLogger as any).listeners = { + exit: [], + message: [], + task: [], + ciKeepAlive: [], + timeout: [], + }; }); test('listeners are notified about new messages', () => {