Skip to content

Commit 55eddb8

Browse files
authored
chore(trace): show playwright version in metadata (#38158)
1 parent e9ef0ea commit 55eddb8

File tree

8 files changed

+11
-1
lines changed

8 files changed

+11
-1
lines changed

packages/playwright-core/src/server/trace/recorder/tracing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { assert } from '../../../utils/isomorphic/assert';
2424
import { monotonicTime } from '../../../utils/isomorphic/time';
2525
import { eventsHelper } from '../../utils/eventsHelper';
2626
import { createGuid } from '../../utils/crypto';
27+
import { getPlaywrightVersion } from '../../utils/userAgent';
2728
import { Artifact } from '../../artifact';
2829
import { BrowserContext } from '../../browserContext';
2930
import { Dispatcher } from '../../dispatchers/dispatcher';
@@ -107,6 +108,7 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
107108
type: 'context-options',
108109
origin: 'library',
109110
browserName: '',
111+
playwrightVersion: getPlaywrightVersion(),
110112
options: {},
111113
platform: process.platform,
112114
wallTime: 0,

packages/playwright/src/worker/testTracing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import fs from 'fs';
1818
import path from 'path';
1919

20-
import { ManualPromise, SerializedFS, calculateSha1, createGuid, monotonicTime } from 'playwright-core/lib/utils';
20+
import { ManualPromise, SerializedFS, calculateSha1, createGuid, getPlaywrightVersion, monotonicTime } from 'playwright-core/lib/utils';
2121
import { yauzl, yazl } from 'playwright-core/lib/zipBundle';
2222

2323
import { filteredStackTrace } from '../util';
@@ -57,6 +57,7 @@ export class TestTracing {
5757
type: 'context-options',
5858
origin: 'testRunner',
5959
browserName: '',
60+
playwrightVersion: getPlaywrightVersion(),
6061
options: {},
6162
platform: process.platform,
6263
wallTime: Date.now(),

packages/trace-viewer/src/sw/traceModernizer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export class TraceModernizer {
9191
contextEntry.channel = event.channel;
9292
contextEntry.title = event.title;
9393
contextEntry.platform = event.platform;
94+
contextEntry.playwrightVersion = event.playwrightVersion;
9495
contextEntry.wallTime = event.wallTime;
9596
contextEntry.startTime = event.monotonicTime;
9697
contextEntry.sdkLanguage = event.sdkLanguage;

packages/trace-viewer/src/types/entries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type ContextEntry = {
2727
browserName: string;
2828
channel?: string;
2929
platform?: string;
30+
playwrightVersion?: string;
3031
wallTime: number;
3132
sdkLanguage?: Language;
3233
testIdAttributeName?: string;

packages/trace-viewer/src/ui/metadataView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const MetadataView: React.FunctionComponent<{
3535
<div className='call-line'>engine:<span className='call-value string' title={model.browserName}>{model.browserName}</span></div>
3636
{model.channel && <div className='call-line'>channel:<span className='call-value string' title={model.channel}>{model.channel}</span></div>}
3737
{model.platform && <div className='call-line'>platform:<span className='call-value string' title={model.platform}>{model.platform}</span></div>}
38+
{model.playwrightVersion && <div className='call-line'>playwright version:<span className='call-value string' title={model.playwrightVersion}>{model.playwrightVersion}</span></div>}
3839
{model.options.userAgent && <div className='call-line'>user agent:<span className='call-value datetime' title={model.options.userAgent}>{model.options.userAgent}</span></div>}
3940
{model.options.baseURL && (
4041
<>

packages/trace-viewer/src/ui/modelUtil.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class MultiTraceModel {
6767
readonly browserName: string;
6868
readonly channel?: string;
6969
readonly platform?: string;
70+
readonly playwrightVersion?: string;
7071
readonly wallTime?: number;
7172
readonly title?: string;
7273
readonly options: trace.BrowserContextEventOptions;
@@ -98,6 +99,7 @@ export class MultiTraceModel {
9899
this.channel = libraryContext?.channel;
99100
this.testIdAttributeName = libraryContext?.testIdAttributeName;
100101
this.platform = libraryContext?.platform || '';
102+
this.playwrightVersion = contexts.find(c => c.playwrightVersion)?.playwrightVersion;
101103
this.title = libraryContext?.title || '';
102104
this.options = libraryContext?.options || {};
103105
// Next call updates all timestamps for all events in library contexts, so it must be done first.

packages/trace/src/trace.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type ContextCreatedTraceEvent = {
3838
browserName: string,
3939
channel?: string,
4040
platform: string,
41+
playwrightVersion?: string,
4142
wallTime: number,
4243
monotonicTime: number,
4344
title?: string,

tests/library/trace-viewer.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ test('should include metainfo', async ({ showTraceViewer }) => {
10881088
await expect(callLine.getByText('duration')).toHaveText(/duration:[\dms]+/);
10891089
await expect(callLine.getByText('engine')).toHaveText(/engine:[\w]+/);
10901090
await expect(callLine.getByText('platform')).toHaveText(/platform:[\w]+/);
1091+
await expect(callLine.getByText('playwright version')).toHaveText(/playwright version:[\w.]+/);
10911092
await expect(callLine.getByText('width')).toHaveText(/width:[\d]+/);
10921093
await expect(callLine.getByText('height')).toHaveText(/height:[\d]+/);
10931094
await expect(callLine.getByText('pages')).toHaveText(/pages:1/);

0 commit comments

Comments
 (0)