Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/playwright/src/reporters/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import path from 'path';
import { isPathInside } from '@utils/fileUtils';
import { ZipFile } from '@utils/zipFile';

import { formatError, terminalScreen } from './base';
import { currentBlobReportVersion } from './blob';
import { Multiplexer } from './multiplexer';
import { JsonStringInternalizer, StringInternPool } from '../isomorphic/stringInternPool';
Expand Down Expand Up @@ -112,8 +113,10 @@ export async function createMergedReport(config: FullConfigInternal, dir: string
});
}
await dispatchEvents(eventData.epilogue);
// The merged report status is intentionally not surfaced as a failure - the
// merge command only fails when a reporter itself errors.
// The merged report status is intentionally not surfaced as a failure.
// Reporter errors still fail the merge command and should be visible.
for (const error of multiplexer.reporterErrors())
terminalScreen.stderr.write(formatError(terminalScreen, error).message + '\n');
return multiplexer.hasReporterErrors() ? 'failed' : 'passed';
}

Expand Down
13 changes: 11 additions & 2 deletions packages/playwright/src/reporters/multiplexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { test } from '../common';
export class Multiplexer implements ReporterV2 {
private _reporters: ReporterV2[];
private _hasReporterErrors = false;
private _reporterErrors: TestError[] = [];

constructor(reporters: ReporterV2[]) {
this._reporters = reporters;
Expand All @@ -36,6 +37,10 @@ export class Multiplexer implements ReporterV2 {
return this._hasReporterErrors;
}

reporterErrors(): TestError[] {
return this._reporterErrors;
}

onConfigure(config: FullConfig) {
for (const reporter of this._reporters)
this._wrap(() => reporter.onConfigure?.(config));
Expand Down Expand Up @@ -122,18 +127,22 @@ export class Multiplexer implements ReporterV2 {
try {
callback();
} catch (e) {
const error = serializeError(e);
this._hasReporterErrors = true;
this._reporterErrors.push(error);
if (redispatch)
this.onError(serializeError(e));
this.onError(error);
}
}

private async _wrapAsync<T>(callback: () => T | Promise<T>): Promise<T | undefined> {
try {
return await callback();
} catch (e) {
const error = serializeError(e);
this._hasReporterErrors = true;
this.onError(serializeError(e));
this._reporterErrors.push(error);
this.onError(error);
}
}
}