From abf4b02804dfec9a13446a84d2d826c3773c671b Mon Sep 17 00:00:00 2001 From: Georgi Davidkov Date: Mon, 18 Mar 2024 23:49:10 +0200 Subject: [PATCH] Built-in reporters expect reporterOption object (#94) --- packages/server/src/Server.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/server/src/Server.ts b/packages/server/src/Server.ts index 10403eb..687e353 100644 --- a/packages/server/src/Server.ts +++ b/packages/server/src/Server.ts @@ -22,7 +22,7 @@ export type ReporterOptions = { [key: string]: string | boolean }; function createPromiseHandle() { let resolve: () => void = () => { throw new Error( - "Expected new Promise callback to be called synchronisously" + "Expected new Promise callback to be called synchronously" ); }; const promise = new Promise(r => (resolve = r)); @@ -42,7 +42,7 @@ export class ClientError extends Error { } export interface ServerConfig { - /** Network hostname to use when istening for clients */ + /** Network hostname to use when listening for clients */ host: string; /** Network port to use when listening for clients */ port: number; @@ -56,6 +56,8 @@ export interface ServerConfig { reporter: Mocha.ReporterConstructor | string; /** Reporter-specific options */ reporterOptions: ReporterOptions; + /** ReporterOptions was previously the only way to specify options to reporter */ + reporterOption?: ReporterOptions; /** Only run tests matching this string or regexp */ grep: string | undefined; /** Inverts grep matches */ @@ -210,8 +212,10 @@ export class Server extends ServerEventEmitter { // When constructing the Reporter we need to (unintuitively) pass all options, not the `options.reporterOptions` const reporter = new Reporter(this.runner as Mocha.Runner, { // alias option name is used in public reporters xunit/tap/progress - reporterOptions: this.config.reporterOptions, - }); + // https://github.com/mochajs/mocha/issues/4153 + reporterOptions: this.config.reporterOptions ?? this.config.reporterOption, + reporterOption: this.config.reporterOption ?? this.config.reporterOptions, + } as { reporterOptions: ReporterOptions, reporterOption: ReporterOptions }); const done = (failures: number) => { this.debug("Testing is done");