diff --git a/packages/playwright-test/src/isomorphic/teleReceiver.ts b/packages/playwright-test/src/isomorphic/teleReceiver.ts index dc66a23597..79a2a93f9b 100644 --- a/packages/playwright-test/src/isomorphic/teleReceiver.ts +++ b/packages/playwright-test/src/isomorphic/teleReceiver.ts @@ -66,10 +66,14 @@ export type JsonTestCase = { testId: string; title: string; location: JsonLocation; + retries: number; +}; + +export type JsonTestEnd = { + testId: string; expectedStatus: TestStatus; timeout: number; annotations: { type: string, description?: string }[]; - retries: number; }; export type JsonTestResultStart = { @@ -127,7 +131,7 @@ export class TeleReporterReceiver { return; } if (method === 'onTestEnd') { - this._onTestEnd(params.testId, params.result); + this._onTestEnd(params.test, params.result); return; } if (method === 'onStepBegin') { @@ -196,8 +200,11 @@ export class TeleReporterReceiver { this._reporter.onTestBegin?.(test, testResult); } - private _onTestEnd(testId: string, payload: JsonTestResultEnd) { - const test = this._tests.get(testId)!; + private _onTestEnd(testEndPayload: JsonTestEnd, payload: JsonTestResultEnd) { + const test = this._tests.get(testEndPayload.testId)!; + test.timeout = testEndPayload.timeout; + test.expectedStatus = testEndPayload.expectedStatus; + test.annotations = testEndPayload.annotations; const result = test.resultsMap.get(payload.id)!; result.duration = payload.duration; result.status = payload.status; @@ -313,10 +320,7 @@ export class TeleReporterReceiver { private _updateTest(payload: JsonTestCase, test: TeleTestCase): TeleTestCase { test.id = payload.testId; - test.expectedStatus = payload.expectedStatus; - test.timeout = payload.timeout; test.location = this._absoluteLocation(payload.location); - test.annotations = payload.annotations; test.retries = payload.retries; return test; } diff --git a/packages/playwright-test/src/reporters/teleEmitter.ts b/packages/playwright-test/src/reporters/teleEmitter.ts index f533195d66..cc34209d64 100644 --- a/packages/playwright-test/src/reporters/teleEmitter.ts +++ b/packages/playwright-test/src/reporters/teleEmitter.ts @@ -16,7 +16,7 @@ import type { FullConfig, FullResult, Reporter, TestError, TestResult, TestStep, Location } from '../../types/testReporter'; import type { Suite, TestCase } from '../common/test'; -import type { JsonConfig, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestResultStart, JsonTestStepEnd, JsonTestStepStart } from '../isomorphic/teleReceiver'; +import type { JsonConfig, JsonProject, JsonSuite, JsonTestCase, JsonTestEnd, JsonTestResultEnd, JsonTestResultStart, JsonTestStepEnd, JsonTestStepStart } from '../isomorphic/teleReceiver'; import type { SuitePrivate } from '../../types/reporterPrivate'; import type { FullConfigInternal, FullProjectInternal } from '../common/types'; import { createGuid } from 'playwright-core/lib/utils'; @@ -53,10 +53,16 @@ export class TeleReporterEmitter implements Reporter { } onTestEnd(test: TestCase, result: TestResult): void { + const testEnd: JsonTestEnd = { + testId: test.id, + expectedStatus: test.expectedStatus, + annotations: test.annotations, + timeout: test.timeout, + }; this._messageSink({ method: 'onTestEnd', params: { - testId: test.id, + test: testEnd, result: this._serializeResultEnd(result), } }); @@ -163,9 +169,6 @@ export class TeleReporterEmitter implements Reporter { testId: test.id, title: test.title, location: this._relativeLocation(test.location), - expectedStatus: test.expectedStatus, - timeout: test.timeout, - annotations: test.annotations, retries: test.retries, }; } diff --git a/tests/playwright-test/ui-mode-test-run.spec.ts b/tests/playwright-test/ui-mode-test-run.spec.ts index 93c7d53919..59221c6bd2 100644 --- a/tests/playwright-test/ui-mode-test-run.spec.ts +++ b/tests/playwright-test/ui-mode-test-run.spec.ts @@ -306,3 +306,27 @@ test('should show time', async ({ runUITest }) => { await expect(page.getByTestId('status-line')).toHaveText('4/8 passed (50%)'); }); + +test('should show test.fail as passing', async ({ runUITest }) => { + const { page } = await runUITest({ + 'a.test.ts': ` + import { test, expect } from '@playwright/test'; + test('should fail', () => { + test.fail(); + expect(1).toBe(2); + }); + `, + }); + await expect.poll(dumpTestTree(page), { timeout: 15000 }).toContain(` + ▼ ◯ a.test.ts + `); + + await page.getByTitle('Run all').click(); + + await expect.poll(dumpTestTree(page, { time: true }), { timeout: 15000 }).toBe(` + ▼ ✅ a.test.ts + ✅ should fail XXms + `); + + await expect(page.getByTestId('status-line')).toHaveText('1/1 passed (100%)'); +});