///
import Mocha from "mocha";
import WebSocket from "ws";
import type { ClientMessage, CustomContext } from "mocha-remote-common";
export type { CustomContext };
import { Debugger } from "./debug";
import { ServerEventEmitter } from "./ServerEventEmitter";
export type ReporterOptions = {
[key: string]: string | boolean;
};
/**
* An error thrown by a connected client
*/
export declare class ClientError extends Error {
readonly ws: WebSocket;
constructor(message: string, ws: WebSocket);
}
export interface ServerConfig {
/** Network hostname to use when listening for clients */
host: string;
/** Network port to use when listening for clients */
port: number;
/** Start the server as soon as it gets constructed */
autoStart: boolean;
/** Start running tests as soon as a client connects */
autoRun: boolean;
/** An ID expected by the clients connecting */
id: string;
/** Specify reporter to use */
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 */
invert: boolean | undefined;
/** Tests needs to complete before this timeout threshold (in milliseconds) */
timeout: number | undefined;
/** Specifies "slow" test threshold (in milliseconds) */
slow: number | undefined;
/** Runtime context sent to client when starting a run */
context: CustomContext | undefined;
}
export declare class Server extends ServerEventEmitter {
static DEFAULT_CONFIG: ServerConfig;
private static debugCounter;
private static nextDebug;
readonly stopped: Promise;
readonly config: ServerConfig;
private readonly debug;
private wss?;
private client?;
private runner?;
private stoppedPromiseHandle;
/** The options to send to the next connecting running client */
private clientOptions?;
private _listening;
constructor(config?: Partial, debug?: Debugger);
start(): Promise;
stop(code?: number, reason?: string): Promise;
get listening(): boolean;
run(fn: (failures: number) => void, context?: CustomContext): Mocha.Runner;
runAndStop(context?: CustomContext): Promise;
get port(): number;
get url(): string;
send(msg: ClientMessage): void;
private handleConnection;
private handleMessage;
/**
* Resets the server for another test run.
*/
private handleReset;
/**
* @param reporter A constructor or a string containing the name of a builtin reporter or the module name or relative path of one.
* @returns A constructor for the reporter.
* @see {Mocha.prototype.reporter}
*/
private determineReporterConstructor;
}