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
chore: add location named property to annotations (#35373)
Adam Gastineau92c5d656ab97
diff --git a/docs/src/test-api/class-testinfo.md b/docs/src/test-api/class-testinfo.mdindex 93cbc93b75..e5e6963af3 100644--- a/docs/src/test-api/class-testinfo.md+++ b/docs/src/test-api/class-testinfo.md@@ -19,6 +19,7 @@ test('basic test', async ({ page }, testInfo) => {- type: <[Array]<[Object]>>- `type` <[string]> Annotation type, for example `'skip'` or `'fail'`.- `description` ?<[string]> Optional description.+ - `location` ?<[Location]> Optional location in the source where the annotation is added.The list of annotations applicable to the current test. Includes annotations from the test, annotations from all [`method: Test.describe`] groups the test belongs to and file-level annotations for the test file.diff --git a/docs/src/test-reporter-api/class-testcase.md b/docs/src/test-reporter-api/class-testcase.mdindex 1aa5379ac4..7bd948bcb4 100644--- a/docs/src/test-reporter-api/class-testcase.md+++ b/docs/src/test-reporter-api/class-testcase.md@@ -9,6 +9,7 @@- type: <[Array]<[Object]>>- `type` <[string]> Annotation type, for example `'skip'` or `'fail'`.- `description` ?<[string]> Optional description.+ - `location` ?<[Location]> Optional location in the source where the annotation is added.The list of annotations applicable to the current test. Includes:* annotations defined on the test or suite via [`method: Test.(call)`] and [`method: Test.describe`];diff --git a/docs/src/test-reporter-api/class-testresult.md b/docs/src/test-reporter-api/class-testresult.mdindex 0e60558632..f8ae95cc75 100644--- a/docs/src/test-reporter-api/class-testresult.md+++ b/docs/src/test-reporter-api/class-testresult.md@@ -19,6 +19,7 @@ The list of files or buffers attached during the test execution through [`proper- type: <[Array]<[Object]>>- `type` <[string]> Annotation type, for example `'skip'` or `'fail'`.- `description` ?<[string]> Optional description.+ - `location` ?<[Location]> Optional location in the source where the annotation is added.The list of annotations appended during test execution. Includes:* annotations implicitly added by methods [`method: Test.skip`], [`method: Test.fixme`] and [`method: Test.fail`] during test execution;diff --git a/docs/src/test-reporter-api/class-teststep.md b/docs/src/test-reporter-api/class-teststep.mdindex 1272eb546f..8cc91b2c4d 100644--- a/docs/src/test-reporter-api/class-teststep.md+++ b/docs/src/test-reporter-api/class-teststep.md@@ -55,6 +55,7 @@ List of steps inside this step.- type: <[Array]<[Object]>>- `type` <[string]> Annotation type, for example `'skip'`.- `description` ?<[string]> Optional description.+ - `location` ?<[Location]> Optional location in the source where the annotation is added.The list of annotations applicable to the current test step.diff --git a/packages/html-reporter/src/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsxindex 56ad193c8c..97da951810 100644--- a/packages/html-reporter/src/testCaseView.tsx+++ b/packages/html-reporter/src/testCaseView.tsx@@ -14,7 +14,8 @@limitations under the License.*/-import type { TestCase, TestAnnotation, TestCaseSummary } from './types';+import type { TestAnnotation } from '@playwright/test';+import type { TestCase, TestCaseSummary } from './types';import * as React from 'react';import { TabbedPane } from './tabbedPane';import { AutoChip } from './chip';diff --git a/packages/html-reporter/src/types.d.ts b/packages/html-reporter/src/types.d.tsindex 17c5a3b373..4225cc050c 100644--- a/packages/html-reporter/src/types.d.ts+++ b/packages/html-reporter/src/types.d.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { Metadata } from '@playwright/test';+import type { TestAnnotation, Metadata } from '@playwright/test';export type Stats = {total: number;@@ -59,8 +59,6 @@ export type TestFileSummary = {stats: Stats;};-export type TestAnnotation = { type: string, description?: string };-export type TestCaseSummary = {testId: string,title: string;diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.tsindex c41af72843..ddc834e07e 100644--- a/packages/playwright/src/common/config.ts+++ b/packages/playwright/src/common/config.ts@@ -36,7 +36,6 @@ export type FixturesWithLocation = {fixtures: Fixtures;location: Location;};-export type Annotation = { type: string, description?: string };export const defaultTimeout = 30000;diff --git a/packages/playwright/src/common/test.ts b/packages/playwright/src/common/test.tsindex 2b6434a2ef..7ef91d27c5 100644--- a/packages/playwright/src/common/test.ts+++ b/packages/playwright/src/common/test.ts@@ -17,9 +17,10 @@import { rootTestType } from './testType';import { computeTestCaseOutcome } from '../isomorphic/teleReceiver';-import type { Annotation, FixturesWithLocation, FullProjectInternal } from './config';+import type { FixturesWithLocation, FullProjectInternal } from './config';import type { FixturePool } from './fixtures';import type { TestTypeImpl } from './testType';+import type { TestAnnotation } from '../../types/test';import type * as reporterTypes from '../../types/testReporter';import type { FullProject, Location } from '../../types/testReporter';@@ -50,7 +51,7 @@ export class Suite extends Base {_timeout: number | undefined;_retries: number | undefined;// Annotations known statically before running the test, e.g. `test.describe.skip()` or `test.describe({ annotation }, body)`.- _staticAnnotations: Annotation[] = [];+ _staticAnnotations: TestAnnotation[] = [];// Explicitly declared tags that are not a part of the title._tags: string[] = [];_modifiers: Modifier[] = [];@@ -252,7 +253,7 @@ export class TestCase extends Base implements reporterTypes.TestCase {expectedStatus: reporterTypes.TestStatus = 'passed';timeout = 0;- annotations: Annotation[] = [];+ annotations: TestAnnotation[] = [];retries = 0;repeatEachIndex = 0;diff --git a/packages/playwright/src/common/testType.ts b/packages/playwright/src/common/testType.tsindex 1fa0f4ce6c..bbe23740a9 100644--- a/packages/playwright/src/common/testType.ts+++ b/packages/playwright/src/common/testType.ts@@ -104,7 +104,7 @@ export class TestTypeImpl {details = fnOrDetails;}- const validatedDetails = validateTestDetails(details);+ const validatedDetails = validateTestDetails(details, location);const test = new TestCase(title, body, this, location);test._requireFile = suite._requireFile;test.annotations.push(...validatedDetails.annotations);@@ -114,9 +114,9 @@ export class TestTypeImpl {if (type === 'only' || type === 'fail.only')test._only = true;if (type === 'skip' || type === 'fixme' || type === 'fail')- test.annotations.push({ type });+ test.annotations.push({ type, location });else if (type === 'fail.only')- test.annotations.push({ type: 'fail' });+ test.annotations.push({ type: 'fail', location });}private _describe(type: 'default' | 'only' | 'serial' | 'serial.only' | 'parallel' | 'parallel.only' | 'skip' | 'fixme', location: Location, titleOrFn: string | Function, fnOrDetails?: TestDetails | Function, fn?: Function) {@@ -143,7 +143,7 @@ export class TestTypeImpl {body = fn!;}- const validatedDetails = validateTestDetails(details);+ const validatedDetails = validateTestDetails(details, location);const child = new Suite(title, 'describe');child._requireFile = suite._requireFile;child.location = location;@@ -158,7 +158,7 @@ export class TestTypeImpl {if (type === 'parallel' || type === 'parallel.only')child._parallelMode = 'parallel';if (type === 'skip' || type === 'fixme')- child._staticAnnotations.push({ type });+ child._staticAnnotations.push({ type, location });for (let parent: Suite | undefined = suite; parent; parent = parent.parent) {if (parent._parallelMode === 'serial' && child._parallelMode === 'parallel')@@ -229,7 +229,7 @@ export class TestTypeImpl {if (modifierArgs.length >= 1 && !modifierArgs[0])return;const description = modifierArgs[1];- suite._staticAnnotations.push({ type, description });+ suite._staticAnnotations.push({ type, description, location });}return;}@@ -239,7 +239,7 @@ export class TestTypeImpl {throw new Error(`test.${type}() can only be called inside test, describe block or fixture`);if (typeof modifierArgs[0] === 'function')throw new Error(`test.${type}() with a function can only be called inside describe block`);- testInfo[type](...modifierArgs as [any, any]);+ testInfo._modifier(type, location, modifierArgs as [any, any]);}private _setTimeout(location: Location, timeout: number) {@@ -276,7 +276,7 @@ export class TestTypeImpl {let result: Awaited<ReturnType<typeof raceAgainstDeadline<T>>> | undefined = undefined;result = await raceAgainstDeadline(async () => {try {- return await step.info._runStepBody(expectation === 'skip', body);+ return await step.info._runStepBody(expectation === 'skip', body, step.location);} catch (e) {// If the step timed out, the test fixtures will tear down, which in turn// will abort unfinished actions in the step body. Record such errors here.@@ -315,8 +315,9 @@ function throwIfRunningInsideJest() {}}-function validateTestDetails(details: TestDetails) {- const annotations = Array.isArray(details.annotation) ? details.annotation : (details.annotation ? [details.annotation] : []);+function validateTestDetails(details: TestDetails, location: Location) {+ const originalAnnotations = Array.isArray(details.annotation) ? details.annotation : (details.annotation ? [details.annotation] : []);+ const annotations = originalAnnotations.map(annotation => ({ ...annotation, location }));const tags = Array.isArray(details.tag) ? details.tag : (details.tag ? [details.tag] : []);for (const tag of tags) {if (tag[0] !== '@')diff --git a/packages/playwright/src/isomorphic/teleReceiver.ts b/packages/playwright/src/isomorphic/teleReceiver.tsindex 39a3461d8a..8f22a55d84 100644--- a/packages/playwright/src/isomorphic/teleReceiver.ts+++ b/packages/playwright/src/isomorphic/teleReceiver.ts@@ -14,9 +14,8 @@* limitations under the License.*/-import type { Metadata } from '../../types/test';+import type { Metadata, TestAnnotation } from '../../types/test';import type * as reporterTypes from '../../types/testReporter';-import type { Annotation } from '../common/config';import type { ReporterV2 } from '../reporters/reporterV2';export type StringIntern = (s: string) => string;@@ -68,7 +67,7 @@ export type JsonTestCase = {retries: number;tags?: string[];repeatEachIndex: number;- annotations?: Annotation[];+ annotations?: TestAnnotation[];};export type JsonTestEnd = {@@ -95,7 +94,7 @@ export type JsonTestResultEnd = {status: reporterTypes.TestStatus;errors: reporterTypes.TestError[];attachments: JsonAttachment[];- annotations?: Annotation[];+ annotations?: TestAnnotation[];};export type JsonTestStepStart = {@@ -112,7 +111,7 @@ export type JsonTestStepEnd = {duration: number;error?: reporterTypes.TestError;attachments?: number[]; // index of JsonTestResultEnd.attachments- annotations?: Annotation[];+ annotations?: TestAnnotation[];};export type JsonFullResult = {@@ -238,7 +237,7 @@ export class TeleReporterReceiver {test.expectedStatus = testEndPayload.expectedStatus;// Should be empty array, but if it's not, it represents all annotations for that testif (testEndPayload.annotations.length > 0)- test.annotations = testEndPayload.annotations;+ test.annotations = this._absoluteAnnotationLocations(testEndPayload.annotations);const result = test.results.find(r => r._id === payload.id)!;result.duration = payload.duration;result.status = payload.status;@@ -246,7 +245,7 @@ export class TeleReporterReceiver {result.error = result.errors?.[0];result.attachments = this._parseAttachments(payload.attachments);if (payload.annotations)- result.annotations = payload.annotations;+ result.annotations = this._absoluteAnnotationLocations(payload.annotations);this._reporter.onTestEnd?.(test, result);// Free up the memory as won't see these step ids.result._stepMap = new Map();@@ -376,10 +375,18 @@ export class TeleReporterReceiver {test.location = this._absoluteLocation(payload.location);test.retries = payload.retries;test.tags = payload.tags ?? [];- test.annotations = payload.annotations ?? [];+ test.annotations = this._absoluteAnnotationLocations(payload.annotations ?? []);return test;}+ private _absoluteAnnotationLocations(annotations: TestAnnotation[]): TestAnnotation[] {+ return annotations.map(annotation => {+ if (annotation.location)+ annotation.location = this._absoluteLocation(annotation.location);+ return annotation;+ });+ }+private _absoluteLocation(location: reporterTypes.Location): reporterTypes.Location;private _absoluteLocation(location?: reporterTypes.Location): reporterTypes.Location | undefined;private _absoluteLocation(location: reporterTypes.Location | undefined): reporterTypes.Location | undefined {@@ -480,7 +487,7 @@ export class TeleTestCase implements reporterTypes.TestCase {expectedStatus: reporterTypes.TestStatus = 'passed';timeout = 0;- annotations: Annotation[] = [];+ annotations: TestAnnotation[] = [];retries = 0;tags: string[] = [];repeatEachIndex = 0;diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.tsindex dfe51127cc..527f0bf3d7 100644--- a/packages/playwright/src/reporters/html.ts+++ b/packages/playwright/src/reporters/html.ts@@ -29,9 +29,9 @@ import { codeFrameColumns } from '../transform/babelBundle';import { resolveReporterOutputPath, stripAnsiEscapes } from '../util';import type { ReporterV2 } from './reporterV2';-import type { Metadata } from '../../types/test';+import type { Metadata, TestAnnotation } from '../../types/test';import type * as api from '../../types/testReporter';-import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep, TestAnnotation } from '@html-reporter/types';+import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep } from '@html-reporter/types';import type { ZipFile } from 'playwright-core/lib/zipBundle';import type { TransformCallback } from 'stream';@@ -503,7 +503,7 @@ class HtmlBuilder {private _serializeAnnotations(annotations: api.TestCase['annotations']): TestAnnotation[] {// Annotations can be pushed directly, with a wrong type.- return annotations.map(a => ({ type: a.type, description: a.description ? String(a.description) : a.description }));+ return annotations.map(a => ({ type: a.type, description: a.description ? String(a.description) : a.description, location: a.location }));}private _createTestResult(test: api.TestCase, result: api.TestResult): TestResult {diff --git a/packages/playwright/src/reporters/merge.ts b/packages/playwright/src/reporters/merge.tsindex 9e2bd2f5df..74f0a9df4e 100644--- a/packages/playwright/src/reporters/merge.ts+++ b/packages/playwright/src/reporters/merge.ts@@ -27,10 +27,10 @@ import { createReporters } from '../runner/reporters';import { relativeFilePath } from '../util';import type { BlobReportMetadata } from './blob';-import type { ReporterDescription } from '../../types/test';+import type { ReporterDescription, TestAnnotation } from '../../types/test';import type { TestError } from '../../types/testReporter';import type { FullConfigInternal } from '../common/config';-import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestStepEnd, JsonTestStepStart } from '../isomorphic/teleReceiver';+import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestEnd, JsonTestResultEnd, JsonTestStepEnd, JsonTestStepStart } from '../isomorphic/teleReceiver';import type * as blobV1 from './versions/blobV1';type StatusCallback = (message: string) => void;@@ -474,7 +474,10 @@ class PathSeparatorPatcher {return;}if (jsonEvent.method === 'onTestEnd') {+ const test = jsonEvent.params.test as JsonTestEnd;+ test.annotations?.forEach(annotation => this._updateAnnotationLocations(annotation));const testResult = jsonEvent.params.result as JsonTestResultEnd;+ testResult.annotations?.forEach(annotation => this._updateAnnotationLocations(annotation));testResult.errors.forEach(error => this._updateErrorLocations(error));testResult.attachments.forEach(attachment => {if (attachment.path)@@ -490,6 +493,7 @@ class PathSeparatorPatcher {if (jsonEvent.method === 'onStepEnd') {const step = jsonEvent.params.step as JsonTestStepEnd;this._updateErrorLocations(step.error);+ step.annotations?.forEach(annotation => this._updateAnnotationLocations(annotation));return;}}@@ -506,10 +510,12 @@ class PathSeparatorPatcher {if (isFileSuite)suite.title = this._updatePath(suite.title);for (const entry of suite.entries) {- if ('testId' in entry)+ if ('testId' in entry) {this._updateLocation(entry.location);- else+ entry.annotations?.forEach(annotation => this._updateAnnotationLocations(annotation));+ } else {this._updateSuite(entry);+ }}}@@ -520,6 +526,10 @@ class PathSeparatorPatcher {}}+ private _updateAnnotationLocations(annotation: TestAnnotation) {+ this._updateLocation(annotation.location);+ }+private _updateLocation(location?: JsonLocation) {if (location)location.file = this._updatePath(location.file);diff --git a/packages/playwright/src/reporters/teleEmitter.ts b/packages/playwright/src/reporters/teleEmitter.tsindex 1e51dff309..524ec1f5c9 100644--- a/packages/playwright/src/reporters/teleEmitter.ts+++ b/packages/playwright/src/reporters/teleEmitter.ts@@ -22,6 +22,7 @@ import { serializeRegexPatterns } from '../isomorphic/teleReceiver';import type { ReporterV2 } from './reporterV2';import type * as reporterTypes from '../../types/testReporter';+import type { TestAnnotation } from '../../types/test';import type * as teleReceiver from '../isomorphic/teleReceiver';export type TeleReporterEmitterOptions = {@@ -216,7 +217,7 @@ export class TeleReporterEmitter implements ReporterV2 {retries: test.retries,tags: test.tags,repeatEachIndex: test.repeatEachIndex,- annotations: test.annotations,+ annotations: this._relativeAnnotationLocations(test.annotations),};}@@ -237,7 +238,7 @@ export class TeleReporterEmitter implements ReporterV2 {status: result.status,errors: result.errors,attachments: this._serializeAttachments(result.attachments),- annotations: result.annotations?.length ? result.annotations : undefined,+ annotations: result.annotations?.length ? this._relativeAnnotationLocations(result.annotations) : undefined,};}@@ -268,10 +269,18 @@ export class TeleReporterEmitter implements ReporterV2 {duration: step.duration,error: step.error,attachments: step.attachments.length ? step.attachments.map(a => result.attachments.indexOf(a)) : undefined,- annotations: step.annotations.length ? step.annotations : undefined,+ annotations: step.annotations.length ? this._relativeAnnotationLocations(step.annotations) : undefined,};}+ private _relativeAnnotationLocations(annotations: TestAnnotation[]): TestAnnotation[] {+ return annotations.map(annotation => {+ if (annotation.location)+ annotation.location = this._relativeLocation(annotation.location);+ return annotation;+ });+ }+private _relativeLocation(location: reporterTypes.Location): reporterTypes.Location;private _relativeLocation(location?: reporterTypes.Location): reporterTypes.Location | undefined;private _relativeLocation(location: reporterTypes.Location | undefined): reporterTypes.Location | undefined {diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.tsindex c53afede79..364e8ed661 100644--- a/packages/playwright/src/util.ts+++ b/packages/playwright/src/util.ts@@ -65,6 +65,18 @@ export function filteredStackTrace(rawStack: RawStack): StackFrame[] {return frames;}+export function filteredLocation(rawStack: RawStack): Location | undefined {+ const frame = filteredStackTrace(rawStack)[0] as StackFrame | undefined;+ if (!frame)+ return undefined;+ return {+ file: frame.file,+ line: frame.line,+ column: frame.column+ };+}++export function serializeError(error: Error | any): TestInfoErrorImpl {if (error instanceof Error)return filterStackTrace(error);diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.tsindex 9d935ce32b..69c1f53200 100644--- a/packages/playwright/src/worker/testInfo.ts+++ b/packages/playwright/src/worker/testInfo.ts@@ -24,16 +24,16 @@ import { filteredStackTrace, getContainedPath, normalizeAndSaveAttachment, trimLimport { TestTracing } from './testTracing';import { testInfoError } from './util';import { FloatingPromiseScope } from './floatingPromiseScope';+import { wrapFunctionWithLocation } from '../transform/transform';import type { RunnableDescription } from './timeoutManager';-import type { FullProject, TestInfo, TestStatus, TestStepInfo } from '../../types/test';+import type { FullProject, TestAnnotation, TestInfo, TestStatus, TestStepInfo } from '../../types/test';import type { FullConfig, Location } from '../../types/testReporter';-import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config';+import type { FullConfigInternal, FullProjectInternal } from '../common/config';import type { AttachmentPayload, StepBeginPayload, StepEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc';import type { TestCase } from '../common/test';import type { StackFrame } from '@protocol/channels';-export interface TestStepInternal {complete(result: { error?: Error | unknown, suggestedRebaseline?: string }): void;info: TestStepInfoImpl@@ -75,6 +75,12 @@ export class TestInfoImpl implements TestInfo {_hasUnhandledError = false;_allowSkips = false;+ // ------------ Main methods ------------+ skip: (arg?: any, description?: string) => void;+ fixme: (arg?: any, description?: string) => void;+ fail: (arg?: any, description?: string) => void;+ slow: (arg?: any, description?: string) => void;+// ------------ TestInfo fields ------------readonly testId: string;readonly repeatEachIndex: number;@@ -92,7 +98,7 @@ export class TestInfoImpl implements TestInfo {readonly fn: Function;expectedStatus: TestStatus;duration: number = 0;- readonly annotations: Annotation[] = [];+ readonly annotations: TestAnnotation[] = [];readonly attachments: TestInfo['attachments'] = [];status: TestStatus = 'passed';snapshotSuffix: string = '';@@ -200,9 +206,14 @@ export class TestInfoImpl implements TestInfo {};this._tracing = new TestTracing(this, workerParams.artifactsDir);++ this.skip = wrapFunctionWithLocation((location, ...args) => this._modifier('skip', location, args));+ this.fixme = wrapFunctionWithLocation((location, ...args) => this._modifier('fixme', location, args));+ this.fail = wrapFunctionWithLocation((location, ...args) => this._modifier('fail', location, args));+ this.slow = wrapFunctionWithLocation((location, ...args) => this._modifier('slow', location, args));}- private _modifier(type: 'skip' | 'fail' | 'fixme' | 'slow', modifierArgs: [arg?: any, description?: string]) {+ _modifier(type: 'skip' | 'fail' | 'fixme' | 'slow', location: Location, modifierArgs: [arg?: any, description?: string]) {if (typeof modifierArgs[1] === 'function') {throw new Error(['It looks like you are calling test.skip() inside the test and pass a callback.',@@ -217,7 +228,7 @@ export class TestInfoImpl implements TestInfo {return;const description = modifierArgs[1];- this.annotations.push({ type, description });+ this.annotations.push({ type, description, location });if (type === 'slow') {this._timeoutManager.slow();} else if (type === 'skip' || type === 'fixme') {@@ -481,29 +492,13 @@ export class TestInfoImpl implements TestInfo {return this._resolveSnapshotPath(undefined, legacyTemplate, pathSegments);}- skip(...args: [arg?: any, description?: string]) {- this._modifier('skip', args);- }-- fixme(...args: [arg?: any, description?: string]) {- this._modifier('fixme', args);- }-- fail(...args: [arg?: any, description?: string]) {- this._modifier('fail', args);- }-- slow(...args: [arg?: any, description?: string]) {- this._modifier('slow', args);- }-setTimeout(timeout: number) {this._timeoutManager.setTimeout(timeout);}}export class TestStepInfoImpl implements TestStepInfo {- annotations: Annotation[] = [];+ annotations: TestAnnotation[] = [];private _testInfo: TestInfoImpl;private _stepId: string;@@ -513,9 +508,9 @@ export class TestStepInfoImpl implements TestStepInfo {this._stepId = stepId;}- async _runStepBody<T>(skip: boolean, body: (step: TestStepInfo) => T | Promise<T>) {+ async _runStepBody<T>(skip: boolean, body: (step: TestStepInfo) => T | Promise<T>, location?: Location) {if (skip) {- this.annotations.push({ type: 'skip' });+ this.annotations.push({ type: 'skip', location });return undefined as T;}try {@@ -535,15 +530,15 @@ export class TestStepInfoImpl implements TestStepInfo {this._attachToStep(await normalizeAndSaveAttachment(this._testInfo.outputPath(), name, options));}- skip(...args: unknown[]) {+ skip = wrapFunctionWithLocation((location: Location, ...args: unknown[]) => {// skip();// skip(condition: boolean, description: string);if (args.length > 0 && !args[0])return;const description = args[1] as (string|undefined);- this.annotations.push({ type: 'skip', description });+ this.annotations.push({ type: 'skip', description, location });throw new StepSkipError(description);- }+ });}export class TestSkipError extends Error {diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.tsindex e7110517ec..10ce032c94 100644--- a/packages/playwright/src/worker/workerMain.ts+++ b/packages/playwright/src/worker/workerMain.ts@@ -32,9 +32,10 @@ import { loadTestFile } from '../common/testLoader';import type { TimeSlot } from './timeoutManager';import type { Location } from '../../types/testReporter';-import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config';+import type { FullConfigInternal, FullProjectInternal } from '../common/config';import type { DonePayload, RunPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc';import type { Suite, TestCase } from '../common/test';+import type { TestAnnotation } from '../../types/test';export class WorkerMain extends ProcessRunner {private _params: WorkerInitParams;@@ -60,7 +61,7 @@ export class WorkerMain extends ProcessRunner {// Suites that had their beforeAll hooks, but not afterAll hooks executed.// These suites still need afterAll hooks to be executed for the proper cleanup.// Contains dynamic annotations originated by modifiers with a callback, e.g. `test.skip(() => true)`.- private _activeSuites = new Map<Suite, Annotation[]>();+ private _activeSuites = new Map<Suite, TestAnnotation[]>();constructor(params: WorkerInitParams) {super();@@ -264,7 +265,7 @@ export class WorkerMain extends ProcessRunner {stepEndPayload => this.dispatchEvent('stepEnd', stepEndPayload),attachment => this.dispatchEvent('attach', attachment));- const processAnnotation = (annotation: Annotation) => {+ const processAnnotation = (annotation: TestAnnotation) => {testInfo.annotations.push(annotation);switch (annotation.type) {case 'fixme':@@ -501,7 +502,7 @@ export class WorkerMain extends ProcessRunner {continue;const fn = async (fixtures: any) => {const result = await modifier.fn(fixtures);- testInfo[modifier.type](!!result, modifier.description);+ testInfo._modifier(modifier.type, modifier.location, [!!result, modifier.description]);};inheritFixtureNames(modifier.fn, fn);runnables.push({@@ -519,12 +520,12 @@ export class WorkerMain extends ProcessRunner {private async _runBeforeAllHooksForSuite(suite: Suite, testInfo: TestInfoImpl) {if (this._activeSuites.has(suite))return;- const extraAnnotations: Annotation[] = [];+ const extraAnnotations: TestAnnotation[] = [];this._activeSuites.set(suite, extraAnnotations);await this._runAllHooksForSuite(suite, testInfo, 'beforeAll', extraAnnotations);}- private async _runAllHooksForSuite(suite: Suite, testInfo: TestInfoImpl, type: 'beforeAll' | 'afterAll', extraAnnotations?: Annotation[]) {+ private async _runAllHooksForSuite(suite: Suite, testInfo: TestInfoImpl, type: 'beforeAll' | 'afterAll', extraAnnotations?: TestAnnotation[]) {// Always run all the hooks, and capture the first error.let firstError: Error | undefined;for (const hook of this._collectHooksAndModifiers(suite, type, testInfo)) {@@ -604,7 +605,7 @@ function buildTestBeginPayload(testInfo: TestInfoImpl): TestBeginPayload {};}-function buildTestEndPayload(testInfo: TestInfoImpl, staticAnnotations: Set<Annotation>): TestEndPayload {+function buildTestEndPayload(testInfo: TestInfoImpl, staticAnnotations: Set<TestAnnotation>): TestEndPayload {return {testId: testInfo.testId,duration: testInfo.duration,diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.tsindex 27991cc5db..a8366fd3c0 100644--- a/packages/playwright/types/test.d.ts+++ b/packages/playwright/types/test.d.ts@@ -2055,6 +2055,10 @@ export type TestDetailsAnnotation = {description?: string;};+export type TestAnnotation = TestDetailsAnnotation & {+ location?: Location;+};+export type TestDetails = {tag?: string | string[];annotation?: TestDetailsAnnotation | TestDetailsAnnotation[];@@ -9410,6 +9414,11 @@ export interface TestInfo {* Optional description.*/description?: string;++ /**+ * Optional location in the source where the annotation is added.+ */+ location?: Location;}>;/**diff --git a/packages/playwright/types/testReporter.d.ts b/packages/playwright/types/testReporter.d.tsindex 0c27925be2..b984539b6b 100644--- a/packages/playwright/types/testReporter.d.ts+++ b/packages/playwright/types/testReporter.d.ts@@ -464,6 +464,11 @@ export interface TestCase {* Optional description.*/description?: string;++ /**+ * Optional location in the source where the annotation is added.+ */+ location?: Location;}>;/**@@ -617,6 +622,11 @@ export interface TestResult {* Optional description.*/description?: string;++ /**+ * Optional location in the source where the annotation is added.+ */+ location?: Location;}>;/**@@ -732,6 +742,11 @@ export interface TestStep {* Optional description.*/description?: string;++ /**+ * Optional location in the source where the annotation is added.+ */+ location?: Location;}>;/**diff --git a/packages/trace-viewer/src/ui/annotationsTab.tsx b/packages/trace-viewer/src/ui/annotationsTab.tsxindex 5a2a34c9f1..2a107c048c 100644--- a/packages/trace-viewer/src/ui/annotationsTab.tsx+++ b/packages/trace-viewer/src/ui/annotationsTab.tsx@@ -18,11 +18,10 @@ import * as React from 'react';import './annotationsTab.css';import { PlaceholderPanel } from './placeholderPanel';import { linkifyText } from '@web/renderUtils';--type Annotation = { type: string; description?: string; };+import type { TestAnnotation } from '@playwright/test';export const AnnotationsTab: React.FunctionComponent<{- annotations: Annotation[],+ annotations: TestAnnotation[],}> = ({ annotations }) => {if (!annotations.length)diff --git a/packages/trace-viewer/src/ui/workbench.tsx b/packages/trace-viewer/src/ui/workbench.tsxindex f9efcd7a98..9949454434 100644--- a/packages/trace-viewer/src/ui/workbench.tsx+++ b/packages/trace-viewer/src/ui/workbench.tsx@@ -42,6 +42,7 @@ import { testStatusIcon, testStatusText } from './testUtils';import type { UITestStatus } from './testUtils';import type { AfterActionTraceEventAttachment } from '@trace/trace';import type { HighlightedElement } from './snapshotTab';+import type { TestAnnotation } from '@playwright/test';export const Workbench: React.FunctionComponent<{model?: modelUtil.MultiTraceModel,@@ -51,7 +52,7 @@ export const Workbench: React.FunctionComponent<{isLive?: boolean,hideTimeline?: boolean,status?: UITestStatus,- annotations?: { type: string; description?: string; }[];+ annotations?: TestAnnotation[];inert?: boolean,onOpenExternally?: (location: modelUtil.SourceLocation) => void,revealSource?: boolean,diff --git a/tests/playwright-test/access-data.spec.ts b/tests/playwright-test/access-data.spec.tsindex 90a12942b1..54f3cd847a 100644--- a/tests/playwright-test/access-data.spec.ts+++ b/tests/playwright-test/access-data.spec.ts@@ -60,7 +60,10 @@ test('should access annotations in fixture', async ({ runInlineTest }) => {});expect(exitCode).toBe(0);const test = report.suites[0].specs[0].tests[0];- expect(test.results[0].annotations).toEqual([{ type: 'slow', description: 'just slow' }, { type: 'myname', description: 'hello' }]);+ expect(test.results[0].annotations).toEqual([+ { type: 'slow', description: 'just slow', location: { file: expect.any(String), line: 10, column: 14 } },+ { type: 'myname', description: 'hello' }+ ]);expect(test.results[0].stdout).toEqual([{ text: 'console.log\n' }]);expect(test.results[0].stderr).toEqual([{ text: 'console.error\n' }]);});diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.tsindex f72eb1486e..723093be2b 100644--- a/tests/playwright-test/reporter-blob.spec.ts+++ b/tests/playwright-test/reporter-blob.spec.ts@@ -1721,6 +1721,9 @@ test('merge reports with different rootDirs and path separators', async ({ runInconsole.log('test:', test.location.file);console.log('test title:', test.titlePath()[2]);}+ onTestEnd(test) {+ console.log('annotations:', test.annotations.map(a => 'type: ' + a.type + ', description: ' + a.description + ', file: ' + a.location.file).join(','));+ }};`,'merge.config.ts': `module.exports = {@@ -1732,7 +1735,7 @@ test('merge reports with different rootDirs and path separators', async ({ runIn};`,'dir1/tests1/a.test.js': `import { test, expect } from '@playwright/test';- test('math 1', async ({}) => { });+ test('math 1', { annotation: { type: 'warning', description: 'Some warning' } }, async ({}) => { });`,};await runInlineTest(files1, { workers: 1 }, undefined, { additionalArgs: ['--config', test.info().outputPath('dir1/playwright.config.ts')] });@@ -1743,7 +1746,7 @@ test('merge reports with different rootDirs and path separators', async ({ runIn};`,'dir2/tests2/b.test.js': `import { test, expect } from '@playwright/test';- test('math 2', async ({}) => { });+ test('math 2', { annotation: { type: 'issue' } }, async ({}) => { });`,};await runInlineTest(files2, { workers: 1 }, undefined, { additionalArgs: ['--config', test.info().outputPath('dir2/playwright.config.ts')] });@@ -1765,12 +1768,16 @@ test('merge reports with different rootDirs and path separators', async ({ runIn{const { exitCode, output } = await mergeReports(allReportsDir, undefined, { additionalArgs: ['--config', 'merge.config.ts'] });+ const testPath1 = test.info().outputPath('mergeRoot', 'tests1', 'a.test.js');+ const testPath2 = test.info().outputPath('mergeRoot', 'tests2', 'b.test.js');expect(exitCode).toBe(0);expect(output).toContain(`rootDir: ${test.info().outputPath('mergeRoot')}`);- expect(output).toContain(`test: ${test.info().outputPath('mergeRoot', 'tests1', 'a.test.js')}`);+ expect(output).toContain(`test: ${testPath1}`);expect(output).toContain(`test title: ${'tests1' + path.sep + 'a.test.js'}`);- expect(output).toContain(`test: ${test.info().outputPath('mergeRoot', 'tests2', 'b.test.js')}`);+ expect(output).toContain(`annotations: type: warning, description: Some warning, file: ${testPath1}`);+ expect(output).toContain(`test: ${testPath2}`);expect(output).toContain(`test title: ${'tests2' + path.sep + 'b.test.js'}`);+ expect(output).toContain(`annotations: type: issue, description: undefined, file: ${testPath2}`);}});@@ -1786,6 +1793,9 @@ test('merge reports without --config preserves path separators', async ({ runInlconsole.log('test:', test.location.file);console.log('test title:', test.titlePath()[2]);}+ onTestEnd(test) {+ console.log('annotations:', test.annotations.map(a => 'type: ' + a.type + ', description: ' + a.description + ', file: ' + a.location.file).join(','));+ }};`,'dir1/playwright.config.ts': `module.exports = {@@ -1793,11 +1803,11 @@ test('merge reports without --config preserves path separators', async ({ runInl};`,'dir1/tests1/a.test.js': `import { test, expect } from '@playwright/test';- test('math 1', async ({}) => { });+ test('math 1', { annotation: { type: 'warning', description: 'Some warning' } }, async ({}) => { });`,'dir1/tests2/b.test.js': `import { test, expect } from '@playwright/test';- test('math 2', async ({}) => { });+ test('math 2', { annotation: { type: 'issue' } }, async ({}) => { });`,};await runInlineTest(files1, { workers: 1 }, undefined, { additionalArgs: ['--config', test.info().outputPath('dir1/playwright.config.ts')] });@@ -1817,11 +1827,15 @@ test('merge reports without --config preserves path separators', async ({ runInlconst { exitCode, output } = await mergeReports(allReportsDir, undefined, { additionalArgs: ['--reporter', './echo-reporter.js'] });expect(exitCode).toBe(0);const otherSeparator = path.sep === '/' ? '\\' : '/';+ const testPath1 = test.info().outputPath('dir1', 'tests1', 'a.test.js').replaceAll(path.sep, otherSeparator);+ const testPath2 = test.info().outputPath('dir1', 'tests2', 'b.test.js').replaceAll(path.sep, otherSeparator);expect(output).toContain(`rootDir: ${test.info().outputPath('dir1').replaceAll(path.sep, otherSeparator)}`);- expect(output).toContain(`test: ${test.info().outputPath('dir1', 'tests1', 'a.test.js').replaceAll(path.sep, otherSeparator)}`);+ expect(output).toContain(`test: ${testPath1}`);expect(output).toContain(`test title: ${'tests1' + otherSeparator + 'a.test.js'}`);- expect(output).toContain(`test: ${test.info().outputPath('dir1', 'tests2', 'b.test.js').replaceAll(path.sep, otherSeparator)}`);+ expect(output).toContain(`annotations: type: warning, description: Some warning, file: ${testPath1}`);+ expect(output).toContain(`test: ${testPath2}`);expect(output).toContain(`test title: ${'tests2' + otherSeparator + 'b.test.js'}`);+ expect(output).toContain(`annotations: type: issue, description: undefined, file: ${testPath2}`);});test('merge reports must not change test ids when there is no need to', async ({ runInlineTest, mergeReports }) => {diff --git a/tests/playwright-test/reporter.spec.ts b/tests/playwright-test/reporter.spec.tsindex b2a68bfeb0..30e253c4b9 100644--- a/tests/playwright-test/reporter.spec.ts+++ b/tests/playwright-test/reporter.spec.ts@@ -584,7 +584,9 @@ test('should report annotations from test declaration', async ({ runInlineTest }const visit = suite => {for (const test of suite.tests || []) {const annotations = test.annotations.map(a => {- return a.description ? a.type + '=' + a.description : a.type;+ const description = a.description ? a.type + '=' + a.description : a.type;+ const location = a.location ? '(' + a.location.line + ':' + a.location.column + ')' : '';+ return description + location;});console.log('\\n%%title=' + test.title + ', annotations=' + annotations.join(','));}@@ -609,7 +611,7 @@ test('should report annotations from test declaration', async ({ runInlineTest }expect(test.info().annotations).toEqual([]);});test('foo', { annotation: { type: 'foo' } }, () => {- expect(test.info().annotations).toEqual([{ type: 'foo' }]);+ expect(test.info().annotations).toEqual([{ type: 'foo', location: { file: expect.any(String), line: 6, column: 11 } }]);});test('foo-bar', {annotation: [@@ -618,8 +620,8 @@ test('should report annotations from test declaration', async ({ runInlineTest }],}, () => {expect(test.info().annotations).toEqual([- { type: 'foo', description: 'desc' },- { type: 'bar' },+ { type: 'foo', description: 'desc', location: { file: expect.any(String), line: 9, column: 11 } },+ { type: 'bar', location: { file: expect.any(String), line: 9, column: 11 } },]);});test.skip('skip-foo', { annotation: { type: 'foo' } }, () => {@@ -636,11 +638,14 @@ test('should report annotations from test declaration', async ({ runInlineTest }});test.describe('suite', { annotation: { type: 'foo' } }, () => {test('foo-suite', () => {- expect(test.info().annotations).toEqual([{ type: 'foo' }]);+ expect(test.info().annotations).toEqual([{ type: 'foo', location: { file: expect.any(String), line: 32, column: 12 } }]);});test.describe('inner', { annotation: { type: 'bar' } }, () => {test('foo-bar-suite', () => {- expect(test.info().annotations).toEqual([{ type: 'foo' }, { type: 'bar' }]);+ expect(test.info().annotations).toEqual([+ { type: 'foo', location: { file: expect.any(String), line: 32, column: 12 } },+ { type: 'bar', location: { file: expect.any(String), line: 36, column: 14 } }+ ]);});});});@@ -657,15 +662,15 @@ test('should report annotations from test declaration', async ({ runInlineTest }expect(result.exitCode).toBe(0);expect(result.outputLines).toEqual([`title=none, annotations=`,- `title=foo, annotations=foo`,- `title=foo-bar, annotations=foo=desc,bar`,- `title=skip-foo, annotations=foo,skip`,- `title=fixme-bar, annotations=bar,fixme`,- `title=fail-foo-bar, annotations=foo,bar=desc,fail`,- `title=foo-suite, annotations=foo`,- `title=foo-bar-suite, annotations=foo,bar`,- `title=skip-foo-suite, annotations=foo,skip`,- `title=fixme-bar-suite, annotations=bar,fixme`,+ `title=foo, annotations=foo(6:11)`,+ `title=foo-bar, annotations=foo=desc(9:11),bar(9:11)`,+ `title=skip-foo, annotations=foo(20:12),skip(20:12)`,+ `title=fixme-bar, annotations=bar(22:12),fixme(22:12)`,+ `title=fail-foo-bar, annotations=foo(24:12),bar=desc(24:12),fail(24:12)`,+ `title=foo-suite, annotations=foo(32:12)`,+ `title=foo-bar-suite, annotations=foo(32:12),bar(36:14)`,+ `title=skip-foo-suite, annotations=foo(45:21),skip(45:21)`,+ `title=fixme-bar-suite, annotations=bar(49:21),fixme(49:21)`,]);});diff --git a/tests/playwright-test/retry.spec.ts b/tests/playwright-test/retry.spec.tsindex 80e4d23123..22b7a9841a 100644--- a/tests/playwright-test/retry.spec.ts+++ b/tests/playwright-test/retry.spec.ts@@ -260,5 +260,5 @@ test('failed and skipped on retry should be marked as flaky', async ({ runInlineexpect(result.failed).toBe(0);expect(result.flaky).toBe(1);expect(result.output).toContain('Failed on first run');- expect(result.report.suites[0].specs[0].tests[0].results[1].annotations).toEqual([{ type: 'skip', description: 'Skipped on first retry' }]);+ expect(result.report.suites[0].specs[0].tests[0].results[1].annotations).toEqual([{ type: 'skip', description: 'Skipped on first retry', location: expect.anything() }]);});diff --git a/tests/playwright-test/test-modifiers.spec.ts b/tests/playwright-test/test-modifiers.spec.tsindex 86b9c2233c..00eb919a49 100644--- a/tests/playwright-test/test-modifiers.spec.ts+++ b/tests/playwright-test/test-modifiers.spec.ts@@ -113,19 +113,19 @@ test('test modifiers should work', async ({ runInlineTest }) => {expectTest('passed3', 'passed', 'passed', []);expectTest('passed4', 'passed', 'passed', []);expectTest('passed5', 'passed', 'passed', []);- expectTest('skipped1', 'skipped', 'skipped', [{ type: 'skip' }]);- expectTest('skipped2', 'skipped', 'skipped', [{ type: 'skip' }]);- expectTest('skipped3', 'skipped', 'skipped', [{ type: 'skip' }]);- expectTest('skipped4', 'skipped', 'skipped', [{ type: 'skip', description: 'reason' }]);- expectTest('skipped5', 'skipped', 'skipped', [{ type: 'fixme' }]);- expectTest('skipped6', 'skipped', 'skipped', [{ type: 'fixme', description: 'reason' }]);- expectTest('failed1', 'failed', 'failed', [{ type: 'fail' }]);- expectTest('failed2', 'failed', 'failed', [{ type: 'fail' }]);- expectTest('failed3', 'failed', 'failed', [{ type: 'fail' }]);- expectTest('failed4', 'failed', 'failed', [{ type: 'fail', description: 'reason' }]);- expectTest('suite1', 'skipped', 'skipped', [{ type: 'skip' }]);- expectTest('suite2', 'skipped', 'skipped', [{ type: 'skip' }]);- expectTest('suite3', 'skipped', 'skipped', [{ type: 'skip', description: 'reason' }]);+ expectTest('skipped1', 'skipped', 'skipped', [{ type: 'skip', location: { file: expect.any(String), line: 20, column: 14 } }]);+ expectTest('skipped2', 'skipped', 'skipped', [{ type: 'skip', location: { file: expect.any(String), line: 23, column: 14 } }]);+ expectTest('skipped3', 'skipped', 'skipped', [{ type: 'skip', location: { file: expect.any(String), line: 26, column: 14 } }]);+ expectTest('skipped4', 'skipped', 'skipped', [{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 29, column: 14 } }]);+ expectTest('skipped5', 'skipped', 'skipped', [{ type: 'fixme', location: { file: expect.any(String), line: 32, column: 14 } }]);+ expectTest('skipped6', 'skipped', 'skipped', [{ type: 'fixme', description: 'reason', location: { file: expect.any(String), line: 35, column: 14 } }]);+ expectTest('failed1', 'failed', 'failed', [{ type: 'fail', location: { file: expect.any(String), line: 39, column: 14 } }]);+ expectTest('failed2', 'failed', 'failed', [{ type: 'fail', location: { file: expect.any(String), line: 43, column: 14 } }]);+ expectTest('failed3', 'failed', 'failed', [{ type: 'fail', location: { file: expect.any(String), line: 47, column: 14 } }]);+ expectTest('failed4', 'failed', 'failed', [{ type: 'fail', description: 'reason', location: { file: expect.any(String), line: 51, column: 14 } }]);+ expectTest('suite1', 'skipped', 'skipped', [{ type: 'skip', location: { file: expect.any(String), line: 56, column: 14 } }]);+ expectTest('suite2', 'skipped', 'skipped', [{ type: 'skip', location: { file: expect.any(String), line: 61, column: 14 } }]);+ expectTest('suite3', 'skipped', 'skipped', [{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 66, column: 14 } }]);expectTest('suite4', 'passed', 'passed', []);expect(result.passed).toBe(10);expect(result.skipped).toBe(9);@@ -407,7 +407,7 @@ test('should skip inside fixture', async ({ runInlineTest }) => {});expect(result.exitCode).toBe(0);expect(result.skipped).toBe(1);- expect(result.report.suites[0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason' }]);+ expect(result.report.suites[0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 5, column: 20 } }]);});test('modifier with a function should throw in the test', async ({ runInlineTest }) => {@@ -460,8 +460,8 @@ test('test.skip with worker fixtures only should skip before hooks and tests', aexpect(result.passed).toBe(1);expect(result.skipped).toBe(2);expect(result.report.suites[0].specs[0].tests[0].annotations).toEqual([]);- expect(result.report.suites[0].suites![0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason' }]);- expect(result.report.suites[0].suites![0].suites![0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason' }]);+ expect(result.report.suites[0].suites![0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 14, column: 14 } }]);+ expect(result.report.suites[0].suites![0].suites![0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 14, column: 14 } }]);expect(result.outputLines).toEqual(['beforeEach','passed',@@ -493,8 +493,8 @@ test('test.skip without a callback in describe block should skip hooks', async (});expect(result.exitCode).toBe(0);expect(result.skipped).toBe(2);- expect(result.report.suites[0].specs[0].tests[0].annotations).toEqual([{ type: 'skip', description: 'reason' }]);- expect(result.report.suites[0].suites![0].specs[0].tests[0].annotations).toEqual([{ type: 'skip', description: 'reason' }]);+ expect(result.report.suites[0].specs[0].tests[0].annotations).toEqual([{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 10, column: 12 } }]);+ expect(result.report.suites[0].suites![0].specs[0].tests[0].annotations).toEqual([{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 10, column: 12 } }]);expect(result.output).not.toContain('%%');});@@ -598,8 +598,8 @@ test('should skip all tests from beforeAll', async ({ runInlineTest }) => {'beforeAll','afterAll',]);- expect(result.report.suites[0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason' }]);- expect(result.report.suites[0].specs[1].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason' }]);+ expect(result.report.suites[0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 5, column: 14 } }]);+ expect(result.report.suites[0].specs[1].tests[0].results[0].annotations).toEqual([{ type: 'skip', description: 'reason', location: { file: expect.any(String), line: 5, column: 14 } }]);});test('should report skipped tests in-order with correct properties', async ({ runInlineTest }) => {@@ -695,9 +695,9 @@ test('static modifiers should be added in serial mode', async ({ runInlineTest }expect(result.passed).toBe(0);expect(result.skipped).toBe(2);expect(result.didNotRun).toBe(1);- expect(result.report.suites[0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'slow' }]);- expect(result.report.suites[0].specs[1].tests[0].annotations).toEqual([{ type: 'fixme' }]);- expect(result.report.suites[0].specs[2].tests[0].annotations).toEqual([{ type: 'skip' }]);+ expect(result.report.suites[0].specs[0].tests[0].results[0].annotations).toEqual([{ type: 'slow', location: { file: expect.any(String), line: 6, column: 14 } }]);+ expect(result.report.suites[0].specs[1].tests[0].annotations).toEqual([{ type: 'fixme', location: { file: expect.any(String), line: 9, column: 12 } }]);+ expect(result.report.suites[0].specs[2].tests[0].annotations).toEqual([{ type: 'skip', location: { file: expect.any(String), line: 11, column: 12 } }]);expect(result.report.suites[0].specs[3].tests[0].annotations).toEqual([]);});@@ -721,9 +721,18 @@ test('should contain only one slow modifier', async ({ runInlineTest }) => {});expect(result.exitCode).toBe(0);expect(result.passed).toBe(1);- expect(result.report.suites[0].specs[0].tests[0].annotations).toEqual([{ type: 'fixme' }, { type: 'issue', description: 'my-value' }]);- expect(result.report.suites[1].specs[0].tests[0].annotations).toEqual([{ type: 'skip' }, { type: 'issue', description: 'my-value' }]);- expect(result.report.suites[2].specs[0].tests[0].annotations).toEqual([{ type: 'slow' }, { type: 'issue', description: 'my-value' }]);+ expect(result.report.suites[0].specs[0].tests[0].annotations).toEqual([+ { type: 'fixme', location: { file: expect.any(String), line: 3, column: 12 } },+ { type: 'issue', description: 'my-value', location: { file: expect.any(String), line: 4, column: 11 } }+ ]);+ expect(result.report.suites[1].specs[0].tests[0].annotations).toEqual([+ { type: 'skip', location: { file: expect.any(String), line: 3, column: 12 } },+ { type: 'issue', description: 'my-value', location: { file: expect.any(String), line: 4, column: 11 } }+ ]);+ expect(result.report.suites[2].specs[0].tests[0].annotations).toEqual([+ { type: 'slow', location: { file: expect.any(String), line: 3, column: 12 } },+ { type: 'issue', description: 'my-value', location: { file: expect.any(String), line: 4, column: 11 } }+ ]);});test('should skip beforeEach hooks upon modifiers', async ({ runInlineTest }) => {diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.tsindex 04121cb281..268f49dbd9 100644--- a/utils/generate_types/overrides-test.d.ts+++ b/utils/generate_types/overrides-test.d.ts@@ -70,6 +70,10 @@ export type TestDetailsAnnotation = {description?: string;};+export type TestAnnotation = TestDetailsAnnotation & {+ location?: Location;+};+export type TestDetails = {tag?: string | string[];annotation?: TestDetailsAnnotation | TestDetailsAnnotation[];