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: remove Step prefix from trace and reports (#36149)
Pavel Feldmanc9d329155d89
diff --git a/packages/playwright/src/matchers/expect.ts b/packages/playwright/src/matchers/expect.tsindex fe28be1932..eb31f21f51 100644--- a/packages/playwright/src/matchers/expect.ts+++ b/packages/playwright/src/matchers/expect.ts@@ -351,13 +351,15 @@ class ExpectMetaInfoProxyHandler implements ProxyHandler<any> {// 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: (matcherName === 'toPass' || this._info.poll) ? 'test.step' : 'expect' as TestStepCategory,+ category,apiName,- title,+ title: formattedTitle,params: args[0] ? { expected: args[0] } : undefined,infectParentStepsWithError: this._info.isSoft,};diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.tsindex 167679ac9a..00a839cb19 100644--- a/packages/playwright/src/util.ts+++ b/packages/playwright/src/util.ts@@ -429,7 +429,7 @@ export function stepTitle(category: TestStepCategory, title: string): string {case 'expect':return `Expect ${escapeWithQuotes(title, '"')}`;case 'test.step':- return `Step ${escapeWithQuotes(title, '"')}`;+ return title;case 'test.attach':return `Attach ${escapeWithQuotes(title, '"')}`;case 'hook':diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.tsindex 47598cf9d0..f945076393 100644--- a/tests/playwright-test/playwright.trace.spec.ts+++ b/tests/playwright-test/playwright.trace.spec.ts@@ -623,7 +623,7 @@ test('should expand expect.toPass', async ({ runInlineTest }, testInfo) => {' Create context',' Fixture "page"',' Create page',- 'Step "toPass"',+ 'Expect "toPass"',' Navigate to "data:"',' Expect "toBe"',' Navigate to "data:"',@@ -940,15 +940,15 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' Fixture "barPage"',' Expect "barPage setup"',' Create page',- ' Step "step in barPage setup"',+ ' step in barPage setup',' Set content',' Expect "beforeAll start"',' Set content',- ' Step "step in beforeAll"',+ ' step in beforeAll',' Set content',' Fixture "barPage"',' Expect "barPage teardown"',- ' Step "step in barPage teardown"',+ ' step in barPage teardown',' Close context',' beforeEach hook',' Fixture "context"',@@ -958,22 +958,22 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' Fixture "fooPage"',' Expect "fooPage setup"',' Set content',- ' Step "step in fooPage setup"',+ ' step in fooPage setup',' Set content',' Expect "beforeEach start"',' Set content',- ' Step "step in beforeEach"',+ ' step in beforeEach',' Set content','After Hooks',' afterEach hook',' Expect "afterEach start"',' Set content',- ' Step "step in afterEach"',+ ' step in afterEach',' Set content',' Fixture "fooPage"',' Expect "fooPage teardown"',' Set content',- ' Step "step in fooPage teardown"',+ ' step in fooPage teardown',' Set content',' Fixture "page"',' Fixture "context"',@@ -981,15 +981,15 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' Fixture "barPage"',' Expect "barPage setup"',' Create page',- ' Step "step in barPage setup"',+ ' step in barPage setup',' Set content',' Expect "afterAll start"',' Set content',- ' Step "step in afterAll"',+ ' step in afterAll',' Set content',' Fixture "barPage"',' Expect "barPage teardown"',- ' Step "step in barPage teardown"',+ ' step in barPage teardown',' Close context','Attach "error-context"','Worker Cleanup',diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.tsindex 2dacfed0ad..18b7f54fe8 100644--- a/tests/playwright-test/reporter-html.spec.ts+++ b/tests/playwright-test/reporter-html.spec.ts@@ -801,7 +801,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {await showReport();await page.getByRole('link', { name: 'example' }).click();- await page.click('text=Step "skipped step title" (skipped)');+ await page.click('text=skipped step title (skipped)');await expect(page.getByTestId('test-snippet')).toContainText(`await test.step.skip('skipped step title', async () => {`);});@@ -826,7 +826,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {await showReport();await page.getByRole('link', { name: 'example' }).click();- await page.click('text=Step "step title" (skipped: conditional step.skip)');+ await page.click('text=step title (skipped: conditional step.skip)');await expect(page.getByTestId('test-snippet')).toContainText(`await test.step('step title', async (step) => {`);});diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.tsindex 1c99f4f950..3998dce492 100644--- a/tests/playwright-test/test-step.spec.ts+++ b/tests/playwright-test/test-step.spec.ts@@ -637,7 +637,7 @@ test('should not propagate errors from within toPass', async ({ runInlineTest })expect(result.exitCode).toBe(0);expect(result.output).toBe(`hook |Before Hooks-test.step |toPass @ a.test.ts:7+test.step |Expect "toPass" @ a.test.ts:7expect | toBe @ a.test.ts:6expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalityexpect | toBe @ a.test.ts:6@@ -664,7 +664,7 @@ test('should show final toPass error', async ({ runInlineTest }) => {expect(result.exitCode).toBe(1);expect(stripAnsi(result.output)).toBe(`hook |Before Hooks-test.step |toPass @ a.test.ts:6+test.step |Expect "toPass" @ a.test.ts:6test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equalityexpect | toBe @ a.test.ts:5expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality@@ -930,7 +930,7 @@ test('step inside toPass', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hookstest.step |step 1 @ a.test.ts:4-test.step | toPass @ a.test.ts:11+test.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 equalityexpect | toBe @ a.test.ts:9@@ -977,7 +977,7 @@ fixture | contextpw:api | Create contextfixture | pagepw:api | Create page-test.step |toPass @ a.test.ts:11+test.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@@ -1028,7 +1028,7 @@ fixture | contextpw:api | Create contextfixture | pagepw:api | Create page-test.step |poll toHaveLength @ a.test.ts:14+test.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:8expect | toBe @ a.test.ts:10@@ -1080,7 +1080,7 @@ pw:api | Create contextfixture | pagepw:api | Create pagepw:api |Set content @ a.test.ts:4-test.step |poll toBe @ a.test.ts:13+test.step |Expect "poll toBe" @ a.test.ts:13expect | toHaveText @ a.test.ts:7test.step | iteration 1 @ a.test.ts:9expect | toBeVisible @ a.test.ts:10@@ -1693,7 +1693,7 @@ fixture | pagepw:api | Create pagepw:api |Set content @ a.test.ts:16expect |toBeInvisible @ a.test.ts:17-test.step | poll toBe @ a.test.ts:7+test.step | Expect "poll toBe" @ a.test.ts:7pw:api | Is visible locator('div') @ a.test.ts:7expect | toBe @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equalitydiff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.tsindex 120b575bea..e87fe9f3fc 100644--- a/tests/playwright-test/ui-mode-trace.spec.ts+++ b/tests/playwright-test/ui-mode-trace.spec.ts@@ -179,9 +179,9 @@ test('should show snapshots for steps', {await expect(page.getByTestId('actions-tree')).toMatchAriaSnapshot(`- tree:- treeitem /Before Hooks \\d+[hmsp]+/- - treeitem /Step "first" \\d+[hmsp]+/- - treeitem /Step "middle" \\d+[hmsp]+/- - treeitem /Step "last" \\d+[hmsp]+/+ - treeitem /first \\d+[hmsp]+/+ - treeitem /middle \\d+[hmsp]+/+ - treeitem /last \\d+[hmsp]+/- treeitem /After Hooks \\d+[hmsp]+/`);