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: do not prefix custom expect titles (#36951)
Dmitry Gozman8b9f4f5967e6
diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.tsindex f2552760e1..53f8bd0a36 100644--- a/packages/playwright/src/index.ts+++ b/packages/playwright/src/index.ts@@ -22,7 +22,6 @@ import { setBoxedStackPrefixes, createGuid, currentZone, debugMode, jsonStringifimport { currentTestInfo } from './common/globals';import { rootTestType } from './common/testType';-import { stepTitle } from './util';import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, VideoMode } from '../types/test';import type { ContextReuseMode } from './common/config';@@ -268,7 +267,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({if (zone.apiName)data.apiName = zone.apiName;if (zone.title)- data.title = stepTitle(zone.category, zone.title);+ data.title = zone.title;data.stepId = zone.stepId;return;}diff --git a/packages/playwright/src/matchers/expect.ts b/packages/playwright/src/matchers/expect.tsindex eb31f21f51..507ca80bf8 100644--- a/packages/playwright/src/matchers/expect.ts+++ b/packages/playwright/src/matchers/expect.ts@@ -18,6 +18,7 @@ import {captureRawStack,createGuid,currentZone,+ escapeWithQuotes,isString,pollAgainstDeadline } from 'playwright-core/lib/utils';@@ -67,8 +68,7 @@ import { TestInfoImpl } from '../worker/testInfo';import type { ExpectMatcherStateInternal } from './matchers';import type { Expect } from '../../types/test';-import type { TestStepInfoImpl } from '../worker/testInfo';-import type { TestStepCategory } from '../util';+import type { TestStepCategory, TestStepInfoImpl } from '../worker/testInfo';// #region@@ -345,21 +345,20 @@ class ExpectMetaInfoProxyHandler implements ProxyHandler<any> {const argsSuffix = computeArgsSuffix(matcherName, args);const defaultTitle = `${this._info.poll ? 'poll ' : ''}${this._info.isSoft ? 'soft ' : ''}${this._info.isNot ? 'not ' : ''}${matcherName}${argsSuffix}`;- const title = customMessage || defaultTitle;+ const title = customMessage || `Expect ${escapeWithQuotes(defaultTitle, '"')}`;const apiName = `expect${this._info.poll ? '.poll ' : ''}${this._info.isSoft ? '.soft ' : ''}${this._info.isNot ? '.not' : ''}.${matcherName}${argsSuffix}`;// This looks like it is unnecessary, but it isn't - we need to filter// out all the frames that belong to the test runner from caught runtime errors.const stackFrames = filteredStackTrace(captureRawStack());const category = matcherName === 'toPass' || this._info.poll ? 'test.step' : 'expect' as TestStepCategory;- const formattedTitle = category === 'expect' ? title : `Expect "${title}"`;// toPass and poll matchers can contain other steps, expects and API calls,// so they behave like a retriable step.const stepInfo = {category,apiName,- title: formattedTitle,+ title,params: args[0] ? { expected: args[0] } : undefined,infectParentStepsWithError: this._info.isSoft,};diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.tsindex 35d0443aa3..98a4397705 100644--- a/packages/playwright/src/reporters/html.ts+++ b/packages/playwright/src/reporters/html.ts@@ -26,7 +26,7 @@ import { yazl } from 'playwright-core/lib/zipBundle';import { CommonReporterOptions, formatError, formatResultFailure, internalScreen } from './base';import { codeFrameColumns } from '../transform/babelBundle';-import { resolveReporterOutputPath, stripAnsiEscapes, stepTitle } from '../util';+import { resolveReporterOutputPath, stripAnsiEscapes } from '../util';import type { ReporterV2 } from './reporterV2';import type { HtmlReporterOptions as HtmlReporterConfigOptions, Metadata, TestAnnotation } from '../../types/test';@@ -34,7 +34,6 @@ import type * as api from '../../types/testReporter';import type { HTMLReport, Location, 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';-import type { TestStepCategory } from '../util';type TestEntry = {testCase: TestCase;@@ -545,7 +544,7 @@ class HtmlBuilder {private _createTestStep(dedupedStep: DedupedStep, result: api.TestResult): TestStep {const { step, duration, count } = dedupedStep;const skipped = dedupedStep.step.annotations?.find(a => a.type === 'skip');- let title = stepTitle(step.category as TestStepCategory, step.title);+ let title = step.title;if (skipped)title = `${title} (skipped${skipped.description ? ': ' + skipped.description : ''})`;const testStep: TestStep = {diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.tsindex bc06ac02f8..19116a9ae9 100644--- a/packages/playwright/src/util.ts+++ b/packages/playwright/src/util.ts@@ -19,7 +19,7 @@ import path from 'path';import url from 'url';import util from 'util';-import { rewriteErrorMessage, toPosixPath, parseStackFrame, sanitizeForFilePath, calculateSha1, isRegExp, isString, stringifyStackFrames, escapeWithQuotes } from 'playwright-core/lib/utils';+import { rewriteErrorMessage, toPosixPath, parseStackFrame, sanitizeForFilePath, calculateSha1, isRegExp, isString, stringifyStackFrames } from 'playwright-core/lib/utils';import { colors, debug, mime, minimatch } from 'playwright-core/lib/utilsBundle';import type { Location } from './../types/testReporter';@@ -423,26 +423,6 @@ export function stripAnsiEscapes(str: string): string {return str.replace(ansiRegex, '');}-export type TestStepCategory = 'expect' | 'fixture' | 'hook' | 'pw:api' | 'test.step' | 'test.attach';--export function stepTitle(category: TestStepCategory, title: string): string {- switch (category) {- case 'fixture':- return `Fixture ${escapeWithQuotes(title, '"')}`;- case 'expect':- return `Expect ${escapeWithQuotes(title, '"')}`;- case 'test.step':- return title;- case 'test.attach':- return `Attach ${escapeWithQuotes(title, '"')}`;- case 'hook':- case 'pw:api':- return title;- default:- return `[${category}] ${title}`;- }-}-type TestFileFilterData = {titlePath: string[][],};diff --git a/packages/playwright/src/worker/fixtureRunner.ts b/packages/playwright/src/worker/fixtureRunner.tsindex bab1ab8e9f..818f1a9ba4 100644--- a/packages/playwright/src/worker/fixtureRunner.ts+++ b/packages/playwright/src/worker/fixtureRunner.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { ManualPromise } from 'playwright-core/lib/utils';+import { escapeWithQuotes, ManualPromise } from 'playwright-core/lib/utils';import { fixtureParameterNames } from '../common/fixtures';import { filterStackFile, formatLocation } from '../util';@@ -46,7 +46,7 @@ class Fixture {const isUserFixture = this.registration.location && filterStackFile(this.registration.location.file);const title = this.registration.customTitle || this.registration.name;const location = isUserFixture ? this.registration.location : undefined;- this._stepInfo = { title, category: 'fixture', location };+ this._stepInfo = { title: `Fixture ${escapeWithQuotes(title, '"')}`, category: 'fixture', location };if (this.registration.box)this._stepInfo.visibility = isUserFixture ? 'hidden' : 'internal';this._setupDescription = {diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.tsindex 64056bb9e2..eb590b0abd 100644--- a/packages/playwright/src/worker/testInfo.ts+++ b/packages/playwright/src/worker/testInfo.ts@@ -17,7 +17,7 @@import fs from 'fs';import path from 'path';-import { captureRawStack, monotonicTime, sanitizeForFilePath, stringifyStackFrames, currentZone, createGuid } from 'playwright-core/lib/utils';+import { captureRawStack, monotonicTime, sanitizeForFilePath, stringifyStackFrames, currentZone, createGuid, escapeWithQuotes } from 'playwright-core/lib/utils';import { TimeoutManager, TimeoutManagerError, kMaxDeadline } from './timeoutManager';import { addSuffixToFilePath, filteredStackTrace, getContainedPath, normalizeAndSaveAttachment, sanitizeFilePathBeforeExtension, trimLongString, windowsFilesystemFriendlyLength } from '../util';@@ -32,9 +32,9 @@ 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';-import type { TestStepCategory } from '../util';export type TestStepVisibility = 'internal' | 'hidden';+export type TestStepCategory = 'expect' | 'fixture' | 'hook' | 'pw:api' | 'test.step' | 'test.attach';interface TestStepData {title: string;@@ -453,7 +453,7 @@ export class TestInfoImpl implements TestInfo {async attach(name: string, options: { path?: string, body?: string | Buffer, contentType?: string } = {}) {const step = this._addStep({- title: name,+ title: `Attach ${escapeWithQuotes(name, '"')}`,category: 'test.attach',});this._attach(await normalizeAndSaveAttachment(this.outputPath(), name, options), step.stepId);@@ -466,7 +466,7 @@ export class TestInfoImpl implements TestInfo {this._stepMap.get(stepId)!.attachmentIndices.push(index);} else {const stepId = `attach@${createGuid()}`;- this._tracing.appendBeforeActionForStep({ stepId, title: attachment.name, category: 'test.attach', stack: [] });+ this._tracing.appendBeforeActionForStep({ stepId, title: `Attach ${escapeWithQuotes(attachment.name, '"')}`, category: 'test.attach', stack: [] });this._tracing.appendAfterActionForStep(stepId, undefined, [attachment]);}diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.tsindex 07b2c56000..3866932103 100644--- a/packages/playwright/src/worker/testTracing.ts+++ b/packages/playwright/src/worker/testTracing.ts@@ -20,15 +20,14 @@ import path from 'path';import { ManualPromise, SerializedFS, calculateSha1, createGuid, monotonicTime } from 'playwright-core/lib/utils';import { yauzl, yazl } from 'playwright-core/lib/zipBundle';-import { filteredStackTrace, stepTitle } from '../util';+import { filteredStackTrace } from '../util';-import type { TestInfoImpl } from './testInfo';+import type { TestStepCategory, TestInfoImpl } from './testInfo';import type { PlaywrightWorkerOptions, TestInfo, TraceMode } from '../../types/test';import type { TestInfoErrorImpl } from '../common/ipc';import type { SerializedError, StackFrame } from '@protocol/channels';import type * as trace from '@trace/trace';import type EventEmitter from 'events';-import type { TestStepCategory } from '../util';export type Attachment = TestInfo['attachments'][0];export const testTraceEntryName = 'test.trace';@@ -273,7 +272,7 @@ export class TestTracing {startTime: monotonicTime(),class: 'Test',method: options.category,- title: stepTitle(options.category, options.title),+ title: options.title,params: Object.fromEntries(Object.entries(options.params || {}).map(([name, value]) => [name, generatePreview(value)])),stack: options.stack,visibility: options.visibility,diff --git a/tests/playwright-test/playwright.reuse.browser.spec.ts b/tests/playwright-test/playwright.reuse.browser.spec.tsindex bce0515314..d172658b94 100644--- a/tests/playwright-test/playwright.reuse.browser.spec.ts+++ b/tests/playwright-test/playwright.reuse.browser.spec.ts@@ -126,26 +126,26 @@ test('should produce correct test steps', async ({ runInlineTest, runServer }) =expect(result.passed).toBe(1);expect(result.outputLines).toEqual(['onStepBegin [hook] Before Hooks',- 'onStepBegin [fixture] browser',+ 'onStepBegin [fixture] Fixture "browser"','onStepBegin [pw:api] connect','onStepEnd [pw:api] connect',- 'onStepEnd [fixture] browser',- 'onStepBegin [fixture] context',- 'onStepEnd [fixture] context',- 'onStepBegin [fixture] page',+ 'onStepEnd [fixture] Fixture "browser"',+ 'onStepBegin [fixture] Fixture "context"',+ 'onStepEnd [fixture] Fixture "context"',+ 'onStepBegin [fixture] Fixture "page"','onStepBegin [pw:api] Create page','onStepEnd [pw:api] Create page',- 'onStepEnd [fixture] page',+ 'onStepEnd [fixture] Fixture "page"','onStepEnd [hook] Before Hooks','onStepBegin [pw:api] Navigate to "about:blank"','onStepEnd [pw:api] Navigate to "about:blank"','onStepBegin [pw:api] Evaluate','onStepEnd [pw:api] Evaluate','onStepBegin [hook] After Hooks',- 'onStepBegin [fixture] page',- 'onStepEnd [fixture] page',- 'onStepBegin [fixture] context',- 'onStepEnd [fixture] context',+ 'onStepBegin [fixture] Fixture "page"',+ 'onStepEnd [fixture] Fixture "page"',+ 'onStepBegin [fixture] Fixture "context"',+ 'onStepEnd [fixture] Fixture "context"','onStepEnd [hook] After Hooks']);});diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.tsindex cf694c244c..ee46887e19 100644--- a/tests/playwright-test/playwright.trace.spec.ts+++ b/tests/playwright-test/playwright.trace.spec.ts@@ -777,7 +777,7 @@ test('should use custom expect message in trace', async ({ runInlineTest }, test' Create context',' Fixture "page"',' Create page',- 'Expect "expect to have text: find a hotel"',+ 'expect to have text: find a hotel','After Hooks',' Fixture "page"',' Fixture "context"',@@ -926,16 +926,16 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' Fixture "browser"',' Launch browser',' Fixture "barPage"',- ' Expect "barPage setup"',+ ' barPage setup',' Create page',' step in barPage setup',' Set content',- ' Expect "beforeAll start"',+ ' beforeAll start',' Set content',' step in beforeAll',' Set content',' Fixture "barPage"',- ' Expect "barPage teardown"',+ ' barPage teardown',' step in barPage teardown',' Close context',' beforeEach hook',@@ -944,22 +944,22 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' Fixture "page"',' Create page',' Fixture "fooPage"',- ' Expect "fooPage setup"',+ ' fooPage setup',' Set content',' step in fooPage setup',' Set content',- ' Expect "beforeEach start"',+ ' beforeEach start',' Set content',' step in beforeEach',' Set content','After Hooks',' afterEach hook',- ' Expect "afterEach start"',+ ' afterEach start',' Set content',' step in afterEach',' Set content',' Fixture "fooPage"',- ' Expect "fooPage teardown"',+ ' fooPage teardown',' Set content',' step in fooPage teardown',' Set content',@@ -968,16 +968,16 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' Close context',' afterAll hook',' Fixture "barPage"',- ' Expect "barPage setup"',+ ' barPage setup',' Create page',' step in barPage setup',' Set content',- ' Expect "afterAll start"',+ ' afterAll start',' Set content',' step in afterAll',' Set content',' Fixture "barPage"',- ' Expect "barPage teardown"',+ ' barPage teardown',' step in barPage teardown',' Close context','Attach "error-context"',@@ -1061,7 +1061,7 @@ test('should attribute worker fixture teardown to the right test', async ({ runIexpect(trace1.actionTree).toEqual(['Before Hooks',' Fixture "foo"',- ' Expect "step in foo setup"',+ ' step in foo setup','After Hooks',]);const trace2 = await parseTrace(testInfo.outputPath('test-results', 'a-two', 'trace.zip'));@@ -1070,7 +1070,7 @@ test('should attribute worker fixture teardown to the right test', async ({ runI'After Hooks','Worker Cleanup',' Fixture "foo"',- ' Expect "step in foo teardown"',+ ' step in foo teardown',]);});diff --git a/tests/playwright-test/reporter.spec.ts b/tests/playwright-test/reporter.spec.tsindex afe152ff7e..9a04c246d9 100644--- a/tests/playwright-test/reporter.spec.ts+++ b/tests/playwright-test/reporter.spec.ts@@ -480,7 +480,7 @@ var import_test = __toModule(require("@playwright/test"));onBegin: 1 tests totalonTestBegin: > a.spec.js > test; retry #0onStepEnd: [hook] Before Hooks-onStepEnd: [expect] toBe+onStepEnd: [expect] Expect "toBe"error: Error: expect(received).toBe(expected) // Object.is equality @ a.spec.js:5======3 | test('test', async () => {@@ -801,7 +801,7 @@ test('attachments are reported in onStepEnd', { annotation: { type: 'issue', desexpect(result.outputLines).toEqual(['[hook] Before Hooks: 0 attachments in result','[test.step] step: 1 attachments in result',- '[test.attach] 4: 2 attachments in result',+ '[test.attach] Attach "4": 2 attachments in result','[hook] After Hooks: 2 attachments in result',]);});diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.tsindex 0842944768..3e472d4311 100644--- a/tests/playwright-test/test-step.spec.ts+++ b/tests/playwright-test/test-step.spec.ts@@ -138,11 +138,11 @@ test('should report api step hierarchy', async ({ runInlineTest }) => {expect(result.exitCode).toBe(0);expect(result.output).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagetest.step |outer step 1 @ a.test.ts:4test.step | inner step 1.1 @ a.test.ts:5@@ -151,8 +151,8 @@ test.step |outer step 2 @ a.test.ts:8test.step | inner step 2.1 @ a.test.ts:9test.step | inner step 2.2 @ a.test.ts:10hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -208,19 +208,19 @@ test('should not report nested after hooks', async ({ runInlineTest }) => {expect(result.exitCode).toBe(1);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagetest.step |my step @ a.test.ts:4hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close contexthook |Worker Cleanup-fixture | browser+fixture | Fixture "browser"|Test timeout of 2000ms exceeded.`);});@@ -267,20 +267,20 @@ test('should report test.step from fixtures', async ({ runInlineTest }) => {expect(result.exitCode).toBe(0);expect(result.outputLines).toEqual([`begin Before Hooks`,- `begin foo`,+ `begin Fixture "foo"`,`begin setup foo`,`end setup foo`,- `end foo`,+ `end Fixture "foo"`,`end Before Hooks`,`begin test step`,`begin inside foo`,`end inside foo`,`end test step`,`begin After Hooks`,- `begin foo`,+ `begin Fixture "foo"`,`begin teardown foo`,`end teardown foo`,- `end foo`,+ `end Fixture "foo"`,`end After Hooks`,]);});@@ -304,7 +304,7 @@ test('should report expect step locations', async ({ runInlineTest }) => {expect(result.exitCode).toBe(0);expect(result.output).toBe(`hook |Before Hooks-expect |toBeTruthy @ a.test.ts:4+expect |Expect "toBeTruthy" @ a.test.ts:4hook |After Hooks`);});@@ -357,8 +357,8 @@ test('should report custom expect steps', async ({ runInlineTest }) => {expect(result.exitCode).toBe(1);expect(result.output).toBe(`hook |Before Hooks-expect |toBeWithinRange @ a.test.ts:32-expect |toBeFailingAsync @ a.test.ts:33+expect |Expect "toBeWithinRange" @ a.test.ts:32+expect |Expect "toBeFailingAsync" @ a.test.ts:33expect |↪ error: Error: It fails!hook |After Hookshook |Worker Cleanup@@ -489,7 +489,7 @@ test.step |outer @ a.test.ts:4test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step | inner @ a.test.ts:5test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | soft toBe @ a.test.ts:6+expect | Expect "soft toBe" @ a.test.ts:6expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step |passing @ a.test.ts:9hook |After Hooks@@ -550,11 +550,11 @@ hook | beforeAll hook @ a.test.ts:3test.step | in beforeAll @ a.test.ts:4hook | beforeEach hook @ a.test.ts:11test.step | in beforeEach @ a.test.ts:12-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagetest.step |grand @ a.test.ts:20test.step | parent1 @ a.test.ts:22@@ -562,12 +562,12 @@ test.step | child1 @ a.test.ts:23pw:api | Click locator('body') @ a.test.ts:24test.step | parent2 @ a.test.ts:27test.step | child2 @ a.test.ts:28-expect | toBeVisible @ a.test.ts:29+expect | Expect "toBeVisible" @ a.test.ts:29hook |After Hookshook | afterEach hook @ a.test.ts:15test.step | in afterEach @ a.test.ts:16-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close contexthook | afterAll hook @ a.test.ts:7test.step | in afterAll @ a.test.ts:8@@ -606,7 +606,7 @@ test('should not mark page.close as failed when page.click fails', async ({ runIexpect(stripAnsi(result.output)).toBe(`hook |Before Hookshook | beforeAll hook @ a.test.ts:5-fixture | browser+fixture | Fixture "browser"pw:api | Launch browserpw:api | Create page @ a.test.ts:6pw:api |Set content @ a.test.ts:15@@ -616,7 +616,7 @@ hook |After Hookshook | afterAll hook @ a.test.ts:9pw:api | Close context @ a.test.ts:10hook |Worker Cleanup-fixture | browser+fixture | Fixture "browser"|Test timeout of 2000ms exceeded.|Error: page.click: Target page, context or browser has been closed`);@@ -641,11 +641,11 @@ test('should not propagate errors from within toPass', async ({ runInlineTest })expect(result.output).toBe(`hook |Before Hookstest.step |Expect "toPass" @ a.test.ts:7-expect | toBe @ a.test.ts:6+expect | Expect "toBe" @ a.test.ts:6expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toBe @ a.test.ts:6+expect | Expect "toBe" @ a.test.ts:6expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toBe @ a.test.ts:6+expect | Expect "toBe" @ a.test.ts:6hook |After Hooks`);});@@ -669,7 +669,7 @@ test('should show final toPass error', async ({ runInlineTest }) => {hook |Before Hookstest.step |Expect "toPass" @ a.test.ts:6test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toBe @ a.test.ts:5+expect | Expect "toBe" @ a.test.ts:5expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalityhook |After Hookshook |Worker Cleanup@@ -706,13 +706,13 @@ test.step |first outer @ a.test.ts:4test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step | first inner @ a.test.ts:5test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | soft toBe @ a.test.ts:6+expect | Expect "soft toBe" @ a.test.ts:6expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step |second outer @ a.test.ts:10test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step | second inner @ a.test.ts:11test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toBe @ a.test.ts:12+expect | Expect "toBe" @ a.test.ts:12expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalityhook |After Hookshook |Worker Cleanup@@ -751,13 +751,13 @@ test('should not propagate nested hard errors', async ({ runInlineTest }) => {hook |Before Hookstest.step |first outer @ a.test.ts:4test.step | first inner @ a.test.ts:5-expect | toBe @ a.test.ts:7+expect | Expect "toBe" @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step |second outer @ a.test.ts:13test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step | second inner @ a.test.ts:14test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toBe @ a.test.ts:15+expect | Expect "toBe" @ a.test.ts:15expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalityhook |After Hookshook |Worker Cleanup@@ -786,7 +786,7 @@ test.step |boxed step @ a.test.ts:3test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equality @ a.test.ts:4test.step | at a.test.ts:4:27test.step | at a.test.ts:3:26-expect | toBe @ a.test.ts:4+expect | Expect "toBe" @ a.test.ts:4expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality @ a.test.ts:4expect | at a.test.ts:4:27expect | at a.test.ts:3:26@@ -821,7 +821,7 @@ hook |Before Hookstest.step |boxed step @ a.test.ts:8test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equality @ a.test.ts:8test.step | at a.test.ts:8:21-expect | toBe @ a.test.ts:5+expect | Expect "toBe" @ a.test.ts:5expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality @ a.test.ts:8expect | at a.test.ts:8:21hook |After Hooks@@ -854,7 +854,7 @@ hook |Before Hookstest.step |boxed step @ a.test.ts:8test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equality @ a.test.ts:8test.step | at a.test.ts:8:21-expect | soft toBe @ a.test.ts:5+expect | Expect "soft toBe" @ a.test.ts:5expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality @ a.test.ts:8expect | at a.test.ts:8:21hook |After Hooks@@ -885,17 +885,17 @@ test('should not generate dupes for named expects', async ({ runInlineTest }) =>expect(result.exitCode).toBe(0);expect(result.output).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagepw:api |Set content @ a.test.ts:4expect |Checking color @ a.test.ts:6hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -937,13 +937,13 @@ test.step |step 1 @ a.test.ts:4test.step | Expect "toPass" @ a.test.ts:11test.step | step 2, attempt: 0 @ a.test.ts:7test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toBe @ a.test.ts:9+expect | Expect "toBe" @ a.test.ts:9expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitytest.step | step 2, attempt: 1 @ a.test.ts:7-expect | toBe @ a.test.ts:9+expect | Expect "toBe" @ a.test.ts:9test.step | step 3 @ a.test.ts:12test.step | step 4 @ a.test.ts:13-expect | toBe @ a.test.ts:14+expect | Expect "toBe" @ a.test.ts:14hook |After Hooks`);});@@ -975,24 +975,24 @@ test('library API call inside toPass', async ({ runInlineTest }) => {expect(result.exitCode).toBe(0);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagetest.step |Expect "toPass" @ a.test.ts:11pw:api | Navigate to "about:blank" @ a.test.ts:6test.step | inner step attempt: 0 @ a.test.ts:7test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toBe @ a.test.ts:9+expect | Expect "toBe" @ a.test.ts:9expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitypw:api | Navigate to "about:blank" @ a.test.ts:6test.step | inner step attempt: 1 @ a.test.ts:7-expect | toBe @ a.test.ts:9+expect | Expect "toBe" @ a.test.ts:9hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1027,25 +1027,25 @@ test('library API call inside expect.poll', async ({ runInlineTest }) => {expect(result.exitCode).toBe(0);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagetest.step |Expect "poll toHaveLength" @ a.test.ts:14pw:api | Navigate to "about:blank" @ a.test.ts:7test.step | inner step attempt: 0 @ a.test.ts:8-expect | toBe @ a.test.ts:10-expect | toHaveLength @ a.test.ts:6+expect | Expect "toBe" @ a.test.ts:10+expect | Expect "toHaveLength" @ a.test.ts:6expect | ↪ error: Error: expect(received).toHaveLength(expected)pw:api | Navigate to "about:blank" @ a.test.ts:7test.step | inner step attempt: 1 @ a.test.ts:8-expect | toBe @ a.test.ts:10-expect | toHaveLength @ a.test.ts:6+expect | Expect "toBe" @ a.test.ts:10+expect | Expect "toHaveLength" @ a.test.ts:6hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1079,26 +1079,26 @@ test('web assertion inside expect.poll', async ({ runInlineTest }) => {expect(result.exitCode).toBe(0);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagepw:api |Set content @ a.test.ts:4test.step |Expect "poll toBe" @ a.test.ts:13-expect | toHaveText @ a.test.ts:7+expect | Expect "toHaveText" @ a.test.ts:7test.step | iteration 1 @ a.test.ts:9-expect | toBeVisible @ a.test.ts:10-expect | toBe @ a.test.ts:6+expect | Expect "toBeVisible" @ a.test.ts:10+expect | Expect "toBe" @ a.test.ts:6expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-expect | toHaveText @ a.test.ts:7+expect | Expect "toHaveText" @ a.test.ts:7test.step | iteration 2 @ a.test.ts:9-expect | toBeVisible @ a.test.ts:10-expect | toBe @ a.test.ts:6+expect | Expect "toBeVisible" @ a.test.ts:10+expect | Expect "toBe" @ a.test.ts:6hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1129,26 +1129,26 @@ test('should report expect steps', async ({ runInlineTest }) => {expect(result.exitCode).toBe(1);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-expect |toBeTruthy @ a.test.ts:4-expect |toBeTruthy @ a.test.ts:5+expect |Expect "toBeTruthy" @ a.test.ts:4+expect |Expect "toBeTruthy" @ a.test.ts:5expect |↪ error: Error: expect(received).toBeTruthy()hook |After Hookshook |Worker Cleanup|Error: expect(received).toBeTruthy()hook |Before Hooks-expect |not toBeTruthy @ a.test.ts:8+expect |Expect "not toBeTruthy" @ a.test.ts:8hook |After Hookshook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create page-expect |not toHaveTitle @ a.test.ts:11+expect |Expect "not toHaveTitle" @ a.test.ts:11hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1218,13 +1218,13 @@ hook |After Hookshook | afterAll hook @ a.test.ts:33pw:api | Close context @ a.test.ts:34hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create page-fixture | request+fixture | Fixture "request"pw:api | Create request contextpw:api |Wait for navigation @ a.test.ts:5pw:api |Navigate to "data:" @ a.test.ts:6@@ -1235,9 +1235,9 @@ pw:api |↪ error: <error message>pw:api |GET "/empty.html" @ a.test.ts:11pw:api |↪ error: <error message>hook |After Hooks-fixture | request-fixture | page-fixture | context+fixture | Fixture "request"+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1262,21 +1262,21 @@ test('should report api step failure', async ({ runInlineTest }) => {expect(result.exitCode).toBe(1);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagepw:api |Set content @ a.test.ts:4pw:api |Click locator('input') @ a.test.ts:5pw:api |↪ error: TimeoutError: page.click: Timeout 1ms exceeded.hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close contexthook |Worker Cleanup-fixture | browser+fixture | Fixture "browser"|TimeoutError: page.click: Timeout 1ms exceeded.`);});@@ -1300,17 +1300,17 @@ test('should show nice stacks for locators', async ({ runInlineTest }) => {expect(result.output).not.toContain('Internal error');expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagepw:api |Set content @ a.test.ts:4pw:api |Evaluate locator('button') @ a.test.ts:6hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1387,11 +1387,11 @@ test('should show tracing.group nested inside test.step', async ({ runInlineTestexpect(result.exitCode).toBe(0);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagetest.step |my step 1 @ a.test.ts:4test.step | my step 2 @ a.test.ts:5@@ -1399,8 +1399,8 @@ pw:api | Trace "my group 1" @ a.test.ts:6pw:api | Trace "my group 2" @ a.test.ts:7pw:api | Set content @ a.test.ts:8hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1438,11 +1438,11 @@ test('calls from waitForEvent callback should be under its parent step', {expect(result.output).not.toContain('Internal error');expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagepw:api |Navigate to "/empty.html" @ a.test.ts:4pw:api |Set content @ a.test.ts:5@@ -1451,11 +1451,11 @@ pw:api | Wait for event "response" @ a.test.ts:7pw:api | Click locator('div') @ a.test.ts:14pw:api | Get content @ a.test.ts:8pw:api | Get content @ a.test.ts:9-expect | toContainText @ a.test.ts:10-expect |toBe @ a.test.ts:18+expect | Expect "toContainText" @ a.test.ts:10+expect |Expect "toBe" @ a.test.ts:18hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1483,18 +1483,18 @@ test('reading network request / response should not be listed as step', {expect(result.exitCode).toBe(0);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagepw:api |Wait for event "request" @ a.test.ts:5pw:api |Wait for event "response" @ a.test.ts:6pw:api |Navigate to "/empty.html" @ a.test.ts:7hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1527,19 +1527,19 @@ test('calls from page.route callback should be under its parent step', {expect(result.output).not.toContain('Internal error');expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagetest.step |custom step @ a.test.ts:4pw:api | Navigate to "/empty.html" @ a.test.ts:12pw:api | GET "/empty.html" @ a.test.ts:6-expect | toBe @ a.test.ts:8+expect | Expect "toBe" @ a.test.ts:8hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1577,7 +1577,7 @@ test.step |outer step 1 @ a.test.ts:4 (skipped)test.step |outer step 2 @ a.test.ts:11test.step | inner step 2.1 @ a.test.ts:12 (skipped)test.step | inner step 2.2 @ a.test.ts:13-expect | toBe @ a.test.ts:14+expect | Expect "toBe" @ a.test.ts:14hook |After Hooks`);});@@ -1606,7 +1606,7 @@ test('skip test.step.skip body', async ({ runInlineTest }) => {hook |Before Hookstest.step |outer step 2 @ a.test.ts:5test.step | inner step 2 @ a.test.ts:6 (skipped)-expect |toBe @ a.test.ts:10+expect |Expect "toBe" @ a.test.ts:10hook |After Hooks`);});@@ -1649,7 +1649,7 @@ test.step | inner step 1.3 @ a.test.ts:11test.step |outer step 2 @ a.test.ts:13test.step | inner step 2.1 @ a.test.ts:14 (skipped)test.step | inner step 2.2 @ a.test.ts:15-expect | toBe @ a.test.ts:16+expect | Expect "toBe" @ a.test.ts:16hook |After Hooks`);});@@ -1672,11 +1672,11 @@ test('step.titlePath works in custom matcher', { annotation: { type: 'issue', de},});test('test', async ({ }) => {- await expect().toHaveTitlePath(['a.test.ts', 'test', 'toHaveTitlePath', 'get titlepath']);+ await expect().toHaveTitlePath(['a.test.ts', 'test', 'Expect "toHaveTitlePath"', 'get titlepath']);await test.step('outer step', async () => {- await expect().toHaveTitlePath(['a.test.ts', 'test', 'outer step', 'toHaveTitlePath', 'get titlepath']);+ await expect().toHaveTitlePath(['a.test.ts', 'test', 'outer step', 'Expect "toHaveTitlePath"', 'get titlepath']);await test.step('inner step', async () => {- await expect().toHaveTitlePath(['a.test.ts', 'test', 'outer step', 'inner step', 'toHaveTitlePath', 'get titlepath']);+ await expect().toHaveTitlePath(['a.test.ts', 'test', 'outer step', 'inner step', 'Expect "toHaveTitlePath"', 'get titlepath']);});});});@@ -1738,34 +1738,34 @@ test('show api calls inside expects', async ({ runInlineTest }) => {expect(result.report.stats.expected).toBe(1);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create pagepw:api |Set content @ a.test.ts:16-expect |toBeInvisible @ a.test.ts:17+expect |Expect "toBeInvisible" @ a.test.ts:17test.step | Expect "poll toBe" @ a.test.ts:7pw:api | Query count locator('div').filter({ visible: true }) @ a.test.ts:7-expect | toBe @ a.test.ts:7+expect | Expect "toBe" @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitypw:api | Query count locator('div').filter({ visible: true }) @ a.test.ts:7-expect | toBe @ a.test.ts:7+expect | Expect "toBe" @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitypw:api | Query count locator('div').filter({ visible: true }) @ a.test.ts:7-expect | toBe @ a.test.ts:7+expect | Expect "toBe" @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitypw:api | Query count locator('div').filter({ visible: true }) @ a.test.ts:7-expect | toBe @ a.test.ts:7+expect | Expect "toBe" @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitypw:api | Query count locator('div').filter({ visible: true }) @ a.test.ts:7-expect | toBe @ a.test.ts:7+expect | Expect "toBe" @ a.test.ts:7pw:api |Wait for timeout @ a.test.ts:18pw:api |Set content @ a.test.ts:19hook |After Hooks-fixture | page-fixture | context+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});@@ -1805,23 +1805,23 @@ test('should box fixtures with everything inside them', async ({ runInlineTest }expect(result.exitCode).toBe(0);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-fixture | browser+fixture | Fixture "browser"pw:api | Launch browser-fixture | context+fixture | Fixture "context"pw:api | Create context-fixture | page+fixture | Fixture "page"pw:api | Create page-fixture | bar @ a.test.ts:4+fixture | Fixture "bar" @ a.test.ts:4pw:api | Set content @ a.test.ts:13test.step | inner step @ a.test.ts:14pw:api | Navigate to "data:" @ a.test.ts:15-expect |toBeVisible @ a.test.ts:22-expect |toBe @ a.test.ts:23-expect |toBe @ a.test.ts:24+expect |Expect "toBeVisible" @ a.test.ts:22+expect |Expect "toBe" @ a.test.ts:23+expect |Expect "toBe" @ a.test.ts:24hook |After Hooks-fixture | bar @ a.test.ts:4-fixture | page-fixture | context+fixture | Fixture "bar" @ a.test.ts:4+fixture | Fixture "page"+fixture | Fixture "context"pw:api | Close context`);});diff --git a/tests/playwright-test/to-have-screenshot.spec.ts b/tests/playwright-test/to-have-screenshot.spec.tsindex b7d6ed5c91..0fea415bf1 100644--- a/tests/playwright-test/to-have-screenshot.spec.ts+++ b/tests/playwright-test/to-have-screenshot.spec.ts@@ -259,17 +259,17 @@ test('should report toHaveScreenshot step with expectation name in title', asyncexpect(result.exitCode).toBe(0);expect(result.outputLines).toEqual([`end [pw:api] Launch browser`,- `end [fixture] browser`,+ `end [fixture] Fixture "browser"`,`end [pw:api] Create context`,- `end [fixture] context`,+ `end [fixture] Fixture "context"`,`end [pw:api] Create page`,- `end [fixture] page`,+ `end [fixture] Fixture "page"`,`end [hook] Before Hooks`,- `end [expect] toHaveScreenshot(foo.png)`,- `end [expect] toHaveScreenshot(is-a-test-1.png)`,- `end [fixture] page`,+ `end [expect] Expect "toHaveScreenshot(foo.png)"`,+ `end [expect] Expect "toHaveScreenshot(is-a-test-1.png)"`,+ `end [fixture] Fixture "page"`,`end [pw:api] Close context`,- `end [fixture] context`,+ `end [fixture] Fixture "context"`,`end [hook] After Hooks`,]);});@@ -703,7 +703,7 @@ test('should attach missing expectations to right step', async ({ runInlineTest}, { reporter: '' });expect(result.exitCode).toBe(1);- expect(result.outputLines).toEqual(['[expect] toHaveScreenshot(snapshot.png): snapshot-expected.png, snapshot-actual.png']);+ expect(result.outputLines).toEqual(['[expect] Expect "toHaveScreenshot(snapshot.png)": snapshot-expected.png, snapshot-actual.png']);});test('shouldn\'t write missing expectations locally for negated matcher', async ({ runInlineTest }, testInfo) => {