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 = {