From e6d16009b9790efec3b2cb1a57fe9267fed8bf95 Mon Sep 17 00:00:00 2001 From: Philipp Fritsche Date: Wed, 11 Dec 2024 09:59:48 +0000 Subject: [PATCH] wip: ui --- util/MockConductor.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/util/MockConductor.ts b/util/MockConductor.ts index a603dd2..c1d79aa 100644 --- a/util/MockConductor.ts +++ b/util/MockConductor.ts @@ -1,6 +1,6 @@ import { setupToolboxTester, TestContext } from '../src' import { TestConductor } from '../src/conductor/TestConductor' -import { TestReporter } from '../src/conductor/TestReporter' +import { TestCompleteData, TestErrorData, TestReporter, TestResultData, TestScheduleData } from '../src/conductor/TestReporter' import { TestHookType } from '../src/conductor/TestRun' import { FsWatcher } from '../src/files/FsWatcher' import { TestRunner } from '../src/runner' @@ -89,10 +89,10 @@ export class MockConductor extends TestConductor { const ctx = {} new TestRunner( { - schedule: async d => reporter.schedule(d), - result: async d => reporter.result(d), - error: async d => reporter.error(d), - complete: async d => reporter.complete(d), + schedule: async d => this.tryReport(reporter, 'schedule', d), + result: async d => this.tryReport(reporter, 'result', d), + error: async d => this.tryReport(reporter, 'error', d), + complete: async d => this.tryReport(reporter, 'complete', d), }, undefined, ctx, @@ -144,6 +144,18 @@ export class MockConductor extends TestConductor { ctx[hook](f as () => void) }) } + + protected tryReport( + reporter: TestReporter, + key: K, + data: Parameters[0], + ) { + try { + reporter[key](data as (TestScheduleData & TestResultData & TestErrorData & TestCompleteData)) + } catch { + return + } + } } export const results: MockResults = {