diff --git a/test/utils/fakeAsync.test.ts b/test/utils/fakeAsync.test.ts index ff46e1b27..87abc06d2 100644 --- a/test/utils/fakeAsync.test.ts +++ b/test/utils/fakeAsync.test.ts @@ -1,8 +1,9 @@ import * as assert from 'assert'; import { delayFor } from 'src/base/common/util/async'; import { FakeAsync, IFakeAsyncOptions } from 'test/utils/fakeAsync'; +import { FakeConsole } from 'test/utils/fakeConsole'; -suite.only('FakeAsync-test', () => { +suite('FakeAsync-test', () => { test('fake the function execution when fake timers are enabled', async () => { let fakeElapsedTime: number = undefined!; @@ -58,10 +59,16 @@ suite.only('FakeAsync-test', () => { }); test('run function with default error handling', async () => { + let errorMessage: any; + FakeConsole.enable({ + onLog: (message) => errorMessage = message + }); + const errorFunction = () => { throw new Error('Test error'); }; - let caughtError: any; await FakeAsync.run(errorFunction); - assert.strictEqual(caughtError.message, 'Test error'); + assert.strictEqual(errorMessage.message, 'Test error'); + + FakeConsole.disable(); }); test('run function with custom error handling', async () => { diff --git a/test/utils/fakeConsole.ts b/test/utils/fakeConsole.ts index d79951511..ba51aa911 100644 --- a/test/utils/fakeConsole.ts +++ b/test/utils/fakeConsole.ts @@ -22,7 +22,7 @@ export namespace FakeConsole { } // callback - options.onLog(message); + options.onLog(message, ...optionalParams); }; } @@ -41,9 +41,11 @@ export interface IFakeConsoleOptions { /** * Callback to recieve the log message. - * @param message the log message. + * @param message The primary message to log. This could be any data type. + * @param optionalParams Additional parameters that may accompany the + * primary message, often used for formatting. */ - readonly onLog?: (message: string) => void; + readonly onLog?: (message: any, ...optionalParams: any[]) => void; } const trueConsole = {