From a83a831037f99e47c36de47040c60c56fe2e1170 Mon Sep 17 00:00:00 2001 From: Mark1626 Date: Sat, 12 Sep 2020 08:28:31 +0530 Subject: [PATCH] feat: Add Console to custom console object --- packages/jest-console/src/BufferedConsole.ts | 2 ++ packages/jest-console/src/CustomConsole.ts | 2 ++ packages/jest-console/src/__tests__/CustomConsole.test.ts | 6 ++++++ packages/jest-console/src/__tests__/bufferedConsole.test.ts | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/packages/jest-console/src/BufferedConsole.ts b/packages/jest-console/src/BufferedConsole.ts index 7ed54795e030..08583a76711b 100644 --- a/packages/jest-console/src/BufferedConsole.ts +++ b/packages/jest-console/src/BufferedConsole.ts @@ -39,6 +39,8 @@ export default class BufferedConsole extends Console { this._groupDepth = 0; } + Console: NodeJS.ConsoleConstructor = Console; + static write( buffer: ConsoleBuffer, type: LogType, diff --git a/packages/jest-console/src/CustomConsole.ts b/packages/jest-console/src/CustomConsole.ts index de38ab55d4a0..34bd357a06e0 100644 --- a/packages/jest-console/src/CustomConsole.ts +++ b/packages/jest-console/src/CustomConsole.ts @@ -37,6 +37,8 @@ export default class CustomConsole extends Console { this._groupDepth = 0; } + Console: NodeJS.ConsoleConstructor = Console; + private _log(type: LogType, message: string) { clearLine(this._stdout); super.log( diff --git a/packages/jest-console/src/__tests__/CustomConsole.test.ts b/packages/jest-console/src/__tests__/CustomConsole.test.ts index 6751a0f63fb3..07bb5cf4f888 100644 --- a/packages/jest-console/src/__tests__/CustomConsole.test.ts +++ b/packages/jest-console/src/__tests__/CustomConsole.test.ts @@ -224,4 +224,10 @@ describe('CustomConsole', () => { _console.timeEnd('custom'); }); }); + + describe('console', () => { + test('should be able to initialize console instance', () => { + expect(_console.Console).toBeDefined(); + }); + }); }); diff --git a/packages/jest-console/src/__tests__/bufferedConsole.test.ts b/packages/jest-console/src/__tests__/bufferedConsole.test.ts index aa9fb36e34f1..8b0ee9f98439 100644 --- a/packages/jest-console/src/__tests__/bufferedConsole.test.ts +++ b/packages/jest-console/src/__tests__/bufferedConsole.test.ts @@ -184,4 +184,10 @@ describe('CustomConsole', () => { _console.timeEnd('custom'); }); }); + + describe('console', () => { + test('should be able to initialize console instance', () => { + expect(_console.Console).toBeDefined(); + }); + }); });