Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/playwright/src/matchers/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
22 changes: 11 additions & 11 deletions tests/playwright-test/playwright.trace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:"',
Expand Down Expand Up @@ -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"',
Expand All @@ -958,38 +958,38 @@ 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"',
' afterAll hook',
' 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',
Expand Down
4 changes: 2 additions & 2 deletions tests/playwright-test/reporter-html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {`);
});

Expand All @@ -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) => {`);
});

Expand Down
14 changes: 7 additions & 7 deletions tests/playwright-test/test-step.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:7
expect | toBe @ a.test.ts:6
expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality
expect | toBe @ a.test.ts:6
Expand All @@ -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:6
test.step |↪ error: Error: expect(received).toBe(expected) // Object.is equality
expect | toBe @ a.test.ts:5
expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality
Expand Down Expand Up @@ -930,7 +930,7 @@ test('step inside toPass', async ({ runInlineTest }) => {
expect(stripAnsi(result.output)).toBe(`
hook |Before Hooks
test.step |step 1 @ a.test.ts:4
test.step | toPass @ a.test.ts:11
test.step | Expect "toPass" @ a.test.ts:11
test.step | step 2, attempt: 0 @ a.test.ts:7
test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality
expect | toBe @ a.test.ts:9
Expand Down Expand Up @@ -977,7 +977,7 @@ fixture | context
pw:api | Create context
fixture | page
pw:api | Create page
test.step |toPass @ a.test.ts:11
test.step |Expect "toPass" @ a.test.ts:11
pw:api | Navigate to "about:blank" @ a.test.ts:6
test.step | inner step attempt: 0 @ a.test.ts:7
test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equality
Expand Down Expand Up @@ -1028,7 +1028,7 @@ fixture | context
pw:api | Create context
fixture | page
pw:api | Create page
test.step |poll toHaveLength @ a.test.ts:14
test.step |Expect "poll toHaveLength" @ a.test.ts:14
pw:api | Navigate to "about:blank" @ a.test.ts:7
test.step | inner step attempt: 0 @ a.test.ts:8
expect | toBe @ a.test.ts:10
Expand Down Expand Up @@ -1080,7 +1080,7 @@ pw:api | Create context
fixture | page
pw:api | Create page
pw:api |Set content @ a.test.ts:4
test.step |poll toBe @ a.test.ts:13
test.step |Expect "poll toBe" @ a.test.ts:13
expect | toHaveText @ a.test.ts:7
test.step | iteration 1 @ a.test.ts:9
expect | toBeVisible @ a.test.ts:10
Expand Down Expand Up @@ -1693,7 +1693,7 @@ fixture | page
pw:api | Create page
pw:api |Set content @ a.test.ts:16
expect |toBeInvisible @ a.test.ts:17
test.step | poll toBe @ a.test.ts:7
test.step | Expect "poll toBe" @ a.test.ts:7
pw:api | Is visible locator('div') @ a.test.ts:7
expect | toBe @ a.test.ts:7
expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality
Expand Down
6 changes: 3 additions & 3 deletions tests/playwright-test/ui-mode-trace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]+/
`);

Expand Down
Loading