Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(blob): store startTime as a number (#24620)
Yury Semikhatsky6c3142959d18
diff --git a/packages/playwright-test/src/isomorphic/teleReceiver.ts b/packages/playwright-test/src/isomorphic/teleReceiver.tsindex 8fb93032b7..39c25c09f8 100644--- a/packages/playwright-test/src/isomorphic/teleReceiver.ts+++ b/packages/playwright-test/src/isomorphic/teleReceiver.ts@@ -87,7 +87,7 @@ export type JsonTestResultStart = {retry: number;workerIndex: number;parallelIndex: number;- startTime: string;+ startTime: number;};export type JsonAttachment = Omit<TestResult['attachments'][0], 'body'> & { base64?: string };@@ -105,7 +105,7 @@ export type JsonTestStepStart = {parentStepId?: string;title: string;category: string,- startTime: string;+ startTime: number;location?: Location;};@@ -232,7 +232,7 @@ export class TeleReporterReceiver {testResult.retry = payload.retry;testResult.workerIndex = payload.workerIndex;testResult.parallelIndex = payload.parallelIndex;- testResult.startTime = new Date(payload.startTime);+ testResult.setStartTimeNumber(payload.startTime);testResult.statusEx = 'running';this._reporter.onTestBegin?.(test, testResult);}@@ -510,22 +510,31 @@ class TeleTestStep implements TestStep {category: string;location: Location | undefined;parent: TestStep | undefined;- startTime: Date;duration: number = -1;steps: TestStep[] = [];+ private _startTime: number = 0;+constructor(payload: JsonTestStepStart, parentStep: TestStep | undefined, location: Location | undefined) {this.title = payload.title;this.category = payload.category;this.location = location;this.parent = parentStep;- this.startTime = new Date(payload.startTime);+ this._startTime = payload.startTime;}titlePath() {const parentPath = this.parent?.titlePath() || [];return [...parentPath, this.title];}++ get startTime(): Date {+ return new Date(this._startTime);+ }++ set startTime(value: Date) {+ this._startTime = +value;+ }}class TeleTestResult implements reporterTypes.TestResult {@@ -533,7 +542,6 @@ class TeleTestResult implements reporterTypes.TestResult {parallelIndex: reporterTypes.TestResult['parallelIndex'] = -1;workerIndex: reporterTypes.TestResult['workerIndex'] = -1;duration: reporterTypes.TestResult['duration'] = -1;- startTime: reporterTypes.TestResult['startTime'] = new Date();stdout: reporterTypes.TestResult['stdout'] = [];stderr: reporterTypes.TestResult['stderr'] = [];attachments: reporterTypes.TestResult['attachments'] = [];@@ -545,9 +553,23 @@ class TeleTestResult implements reporterTypes.TestResult {stepMap: Map<string, reporterTypes.TestStep> = new Map();statusEx: reporterTypes.TestResult['status'] | 'scheduled' | 'running' = 'scheduled';+ private _startTime: number = 0;+constructor(retry: number) {this.retry = retry;}++ setStartTimeNumber(startTime: number) {+ this._startTime = startTime;+ }++ get startTime(): Date {+ return new Date(this._startTime);+ }++ set startTime(value: Date) {+ this._startTime = +value;+ }}export type TeleFullProject = FullProject & { id: string };diff --git a/packages/playwright-test/src/reporters/teleEmitter.ts b/packages/playwright-test/src/reporters/teleEmitter.tsindex d4ba8f45b9..ed91644679 100644--- a/packages/playwright-test/src/reporters/teleEmitter.ts+++ b/packages/playwright-test/src/reporters/teleEmitter.ts@@ -199,7 +199,7 @@ export class TeleReporterEmitter implements ReporterV2 {retry: result.retry,workerIndex: result.workerIndex,parallelIndex: result.parallelIndex,- startTime: result.startTime.toISOString(),+ startTime: +result.startTime,};}@@ -229,7 +229,7 @@ export class TeleReporterEmitter implements ReporterV2 {parentStepId: (step.parent as any)?.[idSymbol],title: step.title,category: step.category,- startTime: step.startTime.toISOString(),+ startTime: +step.startTime,location: this._relativeLocation(step.location),};}diff --git a/tests/playwright-test/reporter.spec.ts b/tests/playwright-test/reporter.spec.tsindex ff6f8ee3dd..870f7cb493 100644--- a/tests/playwright-test/reporter.spec.ts+++ b/tests/playwright-test/reporter.spec.ts@@ -48,6 +48,7 @@ class Reporter {distillStep(step) {return {...step,+ _startTime: undefined,startTime: undefined,duration: undefined,parent: undefined,