Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Ensure Proper Option Passing for JSON Reporter #94

Merged
merged 1 commit into from Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/server/src/Server.ts
Expand Up @@ -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<void>(r => (resolve = r));
Expand All @@ -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;
Expand All @@ -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 */
Expand Down Expand Up @@ -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");
Expand Down