mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: normalize telereceiver type imports (#29745)
This commit is contained in:
parent
0da29959fa
commit
99744d0683
@ -14,7 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { FullConfig, FullResult, Location, TestError, TestResult, TestStatus, TestStep } from '../../types/testReporter';
|
|
||||||
import type { Annotation } from '../common/config';
|
import type { Annotation } from '../common/config';
|
||||||
import type { FullProject, Metadata } from '../../types/test';
|
import type { FullProject, Metadata } from '../../types/test';
|
||||||
import type * as reporterTypes from '../../types/testReporter';
|
import type * as reporterTypes from '../../types/testReporter';
|
||||||
@ -22,17 +21,17 @@ import type { SuitePrivate } from '../../types/reporterPrivate';
|
|||||||
import type { ReporterV2 } from '../reporters/reporterV2';
|
import type { ReporterV2 } from '../reporters/reporterV2';
|
||||||
import { StringInternPool } from './stringInternPool';
|
import { StringInternPool } from './stringInternPool';
|
||||||
|
|
||||||
export type JsonLocation = Location;
|
export type JsonLocation = reporterTypes.Location;
|
||||||
export type JsonError = string;
|
export type JsonError = string;
|
||||||
export type JsonStackFrame = { file: string, line: number, column: number };
|
export type JsonStackFrame = { file: string, line: number, column: number };
|
||||||
|
|
||||||
export type JsonStdIOType = 'stdout' | 'stderr';
|
export type JsonStdIOType = 'stdout' | 'stderr';
|
||||||
|
|
||||||
export type JsonConfig = Pick<FullConfig, 'configFile' | 'globalTimeout' | 'maxFailures' | 'metadata' | 'rootDir' | 'version' | 'workers'> & {
|
export type JsonConfig = Pick<reporterTypes.FullConfig, 'configFile' | 'globalTimeout' | 'maxFailures' | 'metadata' | 'rootDir' | 'version' | 'workers'> & {
|
||||||
listOnly: boolean;
|
listOnly: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MergeReporterConfig = Pick<FullConfig, 'configFile' | 'quiet' | 'reportSlowTests' | 'rootDir' | 'reporter' >;
|
export type MergeReporterConfig = Pick<reporterTypes.FullConfig, 'configFile' | 'quiet' | 'reportSlowTests' | 'rootDir' | 'reporter' >;
|
||||||
|
|
||||||
export type JsonPattern = {
|
export type JsonPattern = {
|
||||||
s?: string;
|
s?: string;
|
||||||
@ -78,7 +77,7 @@ export type JsonTestCase = {
|
|||||||
|
|
||||||
export type JsonTestEnd = {
|
export type JsonTestEnd = {
|
||||||
testId: string;
|
testId: string;
|
||||||
expectedStatus: TestStatus;
|
expectedStatus: reporterTypes.TestStatus;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
annotations: { type: string, description?: string }[];
|
annotations: { type: string, description?: string }[];
|
||||||
};
|
};
|
||||||
@ -91,13 +90,13 @@ export type JsonTestResultStart = {
|
|||||||
startTime: number;
|
startTime: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type JsonAttachment = Omit<TestResult['attachments'][0], 'body'> & { base64?: string };
|
export type JsonAttachment = Omit<reporterTypes.TestResult['attachments'][0], 'body'> & { base64?: string };
|
||||||
|
|
||||||
export type JsonTestResultEnd = {
|
export type JsonTestResultEnd = {
|
||||||
id: string;
|
id: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
status: TestStatus;
|
status: reporterTypes.TestStatus;
|
||||||
errors: TestError[];
|
errors: reporterTypes.TestError[];
|
||||||
attachments: JsonAttachment[];
|
attachments: JsonAttachment[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -107,17 +106,17 @@ export type JsonTestStepStart = {
|
|||||||
title: string;
|
title: string;
|
||||||
category: string,
|
category: string,
|
||||||
startTime: number;
|
startTime: number;
|
||||||
location?: Location;
|
location?: reporterTypes.Location;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type JsonTestStepEnd = {
|
export type JsonTestStepEnd = {
|
||||||
id: string;
|
id: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
error?: TestError;
|
error?: reporterTypes.TestError;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type JsonFullResult = {
|
export type JsonFullResult = {
|
||||||
status: FullResult['status'];
|
status: reporterTypes.FullResult['status'];
|
||||||
startTime: number;
|
startTime: number;
|
||||||
duration: number;
|
duration: number;
|
||||||
};
|
};
|
||||||
@ -137,7 +136,7 @@ export class TeleReporterReceiver {
|
|||||||
private _clearPreviousResultsWhenTestBegins: boolean = false;
|
private _clearPreviousResultsWhenTestBegins: boolean = false;
|
||||||
private _reuseTestCases: boolean;
|
private _reuseTestCases: boolean;
|
||||||
private _reportConfig: MergeReporterConfig | undefined;
|
private _reportConfig: MergeReporterConfig | undefined;
|
||||||
private _config!: FullConfig;
|
private _config!: reporterTypes.FullConfig;
|
||||||
private _stringPool = new StringInternPool();
|
private _stringPool = new StringInternPool();
|
||||||
|
|
||||||
constructor(pathSeparator: string, reporter: Partial<ReporterV2>, reuseTestCases: boolean, reportConfig?: MergeReporterConfig) {
|
constructor(pathSeparator: string, reporter: Partial<ReporterV2>, reuseTestCases: boolean, reportConfig?: MergeReporterConfig) {
|
||||||
@ -290,7 +289,7 @@ export class TeleReporterReceiver {
|
|||||||
this._reporter.onStepEnd?.(test, result, step);
|
this._reporter.onStepEnd?.(test, result, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onError(error: TestError) {
|
private _onError(error: reporterTypes.TestError) {
|
||||||
this._reporter.onError?.(error);
|
this._reporter.onError?.(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +320,7 @@ export class TeleReporterReceiver {
|
|||||||
return this._reporter.onExit?.();
|
return this._reporter.onExit?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _parseConfig(config: JsonConfig): FullConfig {
|
private _parseConfig(config: JsonConfig): reporterTypes.FullConfig {
|
||||||
const result = { ...baseFullConfig, ...config };
|
const result = { ...baseFullConfig, ...config };
|
||||||
if (this._reportConfig) {
|
if (this._reportConfig) {
|
||||||
result.configFile = this._reportConfig.configFile;
|
result.configFile = this._reportConfig.configFile;
|
||||||
@ -353,7 +352,7 @@ export class TeleReporterReceiver {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _parseAttachments(attachments: JsonAttachment[]): TestResult['attachments'] {
|
private _parseAttachments(attachments: JsonAttachment[]): reporterTypes.TestResult['attachments'] {
|
||||||
return attachments.map(a => {
|
return attachments.map(a => {
|
||||||
return {
|
return {
|
||||||
...a,
|
...a,
|
||||||
@ -399,9 +398,9 @@ export class TeleReporterReceiver {
|
|||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _absoluteLocation(location: Location): Location;
|
private _absoluteLocation(location: reporterTypes.Location): reporterTypes.Location;
|
||||||
private _absoluteLocation(location?: Location): Location | undefined;
|
private _absoluteLocation(location?: reporterTypes.Location): reporterTypes.Location | undefined;
|
||||||
private _absoluteLocation(location: Location | undefined): Location | undefined {
|
private _absoluteLocation(location: reporterTypes.Location | undefined): reporterTypes.Location | undefined {
|
||||||
if (!location)
|
if (!location)
|
||||||
return location;
|
return location;
|
||||||
return {
|
return {
|
||||||
@ -422,7 +421,7 @@ export class TeleReporterReceiver {
|
|||||||
|
|
||||||
export class TeleSuite implements SuitePrivate {
|
export class TeleSuite implements SuitePrivate {
|
||||||
title: string;
|
title: string;
|
||||||
location?: Location;
|
location?: reporterTypes.Location;
|
||||||
parent?: TeleSuite;
|
parent?: TeleSuite;
|
||||||
_requireFile: string = '';
|
_requireFile: string = '';
|
||||||
suites: TeleSuite[] = [];
|
suites: TeleSuite[] = [];
|
||||||
@ -470,7 +469,7 @@ export class TeleTestCase implements reporterTypes.TestCase {
|
|||||||
title: string;
|
title: string;
|
||||||
fn = () => {};
|
fn = () => {};
|
||||||
results: TeleTestResult[] = [];
|
results: TeleTestResult[] = [];
|
||||||
location: Location;
|
location: reporterTypes.Location;
|
||||||
parent!: TeleSuite;
|
parent!: TeleSuite;
|
||||||
|
|
||||||
expectedStatus: reporterTypes.TestStatus = 'passed';
|
expectedStatus: reporterTypes.TestStatus = 'passed';
|
||||||
@ -483,7 +482,7 @@ export class TeleTestCase implements reporterTypes.TestCase {
|
|||||||
|
|
||||||
resultsMap = new Map<string, TeleTestResult>();
|
resultsMap = new Map<string, TeleTestResult>();
|
||||||
|
|
||||||
constructor(id: string, title: string, location: Location) {
|
constructor(id: string, title: string, location: reporterTypes.Location) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
@ -531,17 +530,17 @@ export class TeleTestCase implements reporterTypes.TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TeleTestStep implements TestStep {
|
class TeleTestStep implements reporterTypes.TestStep {
|
||||||
title: string;
|
title: string;
|
||||||
category: string;
|
category: string;
|
||||||
location: Location | undefined;
|
location: reporterTypes.Location | undefined;
|
||||||
parent: TestStep | undefined;
|
parent: reporterTypes.TestStep | undefined;
|
||||||
duration: number = -1;
|
duration: number = -1;
|
||||||
steps: TestStep[] = [];
|
steps: reporterTypes.TestStep[] = [];
|
||||||
|
|
||||||
private _startTime: number = 0;
|
private _startTime: number = 0;
|
||||||
|
|
||||||
constructor(payload: JsonTestStepStart, parentStep: TestStep | undefined, location: Location | undefined) {
|
constructor(payload: JsonTestStepStart, parentStep: reporterTypes.TestStep | undefined, location: reporterTypes.Location | undefined) {
|
||||||
this.title = payload.title;
|
this.title = payload.title;
|
||||||
this.category = payload.category;
|
this.category = payload.category;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
@ -571,7 +570,7 @@ class TeleTestResult implements reporterTypes.TestResult {
|
|||||||
stdout: reporterTypes.TestResult['stdout'] = [];
|
stdout: reporterTypes.TestResult['stdout'] = [];
|
||||||
stderr: reporterTypes.TestResult['stderr'] = [];
|
stderr: reporterTypes.TestResult['stderr'] = [];
|
||||||
attachments: reporterTypes.TestResult['attachments'] = [];
|
attachments: reporterTypes.TestResult['attachments'] = [];
|
||||||
status: TestStatus = 'skipped';
|
status: reporterTypes.TestStatus = 'skipped';
|
||||||
steps: TeleTestStep[] = [];
|
steps: TeleTestStep[] = [];
|
||||||
errors: reporterTypes.TestResult['errors'] = [];
|
errors: reporterTypes.TestResult['errors'] = [];
|
||||||
error: reporterTypes.TestResult['error'];
|
error: reporterTypes.TestResult['error'];
|
||||||
@ -600,7 +599,7 @@ class TeleTestResult implements reporterTypes.TestResult {
|
|||||||
|
|
||||||
export type TeleFullProject = FullProject & { __projectId: string };
|
export type TeleFullProject = FullProject & { __projectId: string };
|
||||||
|
|
||||||
export const baseFullConfig: FullConfig = {
|
export const baseFullConfig: reporterTypes.FullConfig = {
|
||||||
forbidOnly: false,
|
forbidOnly: false,
|
||||||
fullyParallel: false,
|
fullyParallel: false,
|
||||||
globalSetup: null,
|
globalSetup: null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user