diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 386d198698..83913c18dc 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -369,9 +369,7 @@ const playwrightFixtures: Fixtures = ({ }); let counter = 0; - let closeReason = testInfo.status === 'timedOut' ? 'Test timeout of ' + testInfo.timeout + 'ms exceeded.' : 'Test ended.'; - if (testInfo.status === 'failed' && testInfo.error?.message?.startsWith('TimeoutError: Step timeout of ')) - closeReason = testInfo.error.message.substring('TimeoutError: '.length); + const closeReason = testInfo.status === 'timedOut' ? 'Test timeout of ' + testInfo.timeout + 'ms exceeded.' : 'Test ended.'; await Promise.all([...contexts.keys()].map(async context => { await (context as any)._wrapApiCall(async () => { await context.close({ reason: closeReason }); diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts index 623100d36f..7d509fda25 100644 --- a/tests/playwright-test/test-step.spec.ts +++ b/tests/playwright-test/test-step.spec.ts @@ -438,7 +438,8 @@ test('step timeout includes interrupted action errors', async ({ runInlineTest } // Should include 2 errors, one for the step timeout and one for the aborted action. expect.soft(result.output).toContain('TimeoutError: Step timeout of 1000ms exceeded.'); expect.soft(result.output).toContain(`> 4 | await test.step('my step', async () => {`); - expect.soft(result.output).toContain('Error: page.waitForTimeout: Step timeout of 1000ms exceeded.'); + expect.soft(result.output).toContain('Error: page.waitForTimeout: Test ended.'); + expect.soft(result.output.split('Error: page.waitForTimeout: Test ended.').length).toBe(2); expect.soft(result.output).toContain('> 5 | await page.waitForTimeout(100_000);'); });