chore: return promise from tele receiver dispatch (#22218)
This commit is contained in:
parent
35afb056ea
commit
b5195122d9
|
|
@ -107,6 +107,11 @@ export type JsonTestStepEnd = {
|
||||||
error?: TestError;
|
error?: TestError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type JsonEvent = {
|
||||||
|
method: string;
|
||||||
|
params: any
|
||||||
|
};
|
||||||
|
|
||||||
export class TeleReporterReceiver {
|
export class TeleReporterReceiver {
|
||||||
private _rootSuite: TeleSuite;
|
private _rootSuite: TeleSuite;
|
||||||
private _pathSeparator: string;
|
private _pathSeparator: string;
|
||||||
|
|
@ -120,8 +125,8 @@ export class TeleReporterReceiver {
|
||||||
this._reporter = reporter;
|
this._reporter = reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(message: any) {
|
dispatch(message: JsonEvent): Promise<void> | undefined {
|
||||||
const { method, params }: { method: string, params: any } = message;
|
const { method, params } = message;
|
||||||
if (method === 'onBegin') {
|
if (method === 'onBegin') {
|
||||||
this._onBegin(params.config, params.projects);
|
this._onBegin(params.config, params.projects);
|
||||||
return;
|
return;
|
||||||
|
|
@ -150,10 +155,10 @@ export class TeleReporterReceiver {
|
||||||
this._onStdIO(params.type, params.testId, params.resultId, params.data, params.isBase64);
|
this._onStdIO(params.type, params.testId, params.resultId, params.data, params.isBase64);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (method === 'onEnd') {
|
if (method === 'onEnd')
|
||||||
this._onEnd(params.result);
|
return this._onEnd(params.result);
|
||||||
return;
|
if (method === 'onExit')
|
||||||
}
|
return this._onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onBegin(config: JsonConfig, projects: JsonProject[]) {
|
private _onBegin(config: JsonConfig, projects: JsonProject[]) {
|
||||||
|
|
@ -258,8 +263,12 @@ export class TeleReporterReceiver {
|
||||||
this._reporter.onStdErr?.(chunk, test, result);
|
this._reporter.onStdErr?.(chunk, test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onEnd(result: FullResult) {
|
private _onEnd(result: FullResult): Promise<void> | undefined {
|
||||||
this._reporter.onEnd?.(result);
|
return this._reporter.onEnd?.(result) || undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onExit(): Promise<void> | undefined {
|
||||||
|
return this._reporter.onExit?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _parseConfig(config: JsonConfig): FullConfig {
|
private _parseConfig(config: JsonConfig): FullConfig {
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ const refreshRootSuite = (eraseResults: boolean): Promise<void> => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
receiver?.dispatch(message);
|
receiver?.dispatch(message)?.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendMessage = async (method: string, params: any) => {
|
const sendMessage = async (method: string, params: any) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue