Skip to content

Commit

Permalink
test: add work-around to jest@27 isolateModules
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Sep 20, 2021
1 parent cba72ed commit ce447c9
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions test/unit/progress-logger.test.ts
@@ -1,19 +1,36 @@
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';

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', () => {
Expand Down

0 comments on commit ce447c9

Please sign in to comment.