chore(ui): update expected state on test end (#22104)
Fixes https://github.com/microsoft/playwright/issues/22096
This commit is contained in:
parent
539d9873c2
commit
eacaf5fc89
|
|
@ -66,10 +66,14 @@ export type JsonTestCase = {
|
||||||
testId: string;
|
testId: string;
|
||||||
title: string;
|
title: string;
|
||||||
location: JsonLocation;
|
location: JsonLocation;
|
||||||
|
retries: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type JsonTestEnd = {
|
||||||
|
testId: string;
|
||||||
expectedStatus: TestStatus;
|
expectedStatus: TestStatus;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
annotations: { type: string, description?: string }[];
|
annotations: { type: string, description?: string }[];
|
||||||
retries: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type JsonTestResultStart = {
|
export type JsonTestResultStart = {
|
||||||
|
|
@ -127,7 +131,7 @@ export class TeleReporterReceiver {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (method === 'onTestEnd') {
|
if (method === 'onTestEnd') {
|
||||||
this._onTestEnd(params.testId, params.result);
|
this._onTestEnd(params.test, params.result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (method === 'onStepBegin') {
|
if (method === 'onStepBegin') {
|
||||||
|
|
@ -196,8 +200,11 @@ export class TeleReporterReceiver {
|
||||||
this._reporter.onTestBegin?.(test, testResult);
|
this._reporter.onTestBegin?.(test, testResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onTestEnd(testId: string, payload: JsonTestResultEnd) {
|
private _onTestEnd(testEndPayload: JsonTestEnd, payload: JsonTestResultEnd) {
|
||||||
const test = this._tests.get(testId)!;
|
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)!;
|
const result = test.resultsMap.get(payload.id)!;
|
||||||
result.duration = payload.duration;
|
result.duration = payload.duration;
|
||||||
result.status = payload.status;
|
result.status = payload.status;
|
||||||
|
|
@ -313,10 +320,7 @@ export class TeleReporterReceiver {
|
||||||
|
|
||||||
private _updateTest(payload: JsonTestCase, test: TeleTestCase): TeleTestCase {
|
private _updateTest(payload: JsonTestCase, test: TeleTestCase): TeleTestCase {
|
||||||
test.id = payload.testId;
|
test.id = payload.testId;
|
||||||
test.expectedStatus = payload.expectedStatus;
|
|
||||||
test.timeout = payload.timeout;
|
|
||||||
test.location = this._absoluteLocation(payload.location);
|
test.location = this._absoluteLocation(payload.location);
|
||||||
test.annotations = payload.annotations;
|
|
||||||
test.retries = payload.retries;
|
test.retries = payload.retries;
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import type { FullConfig, FullResult, Reporter, TestError, TestResult, TestStep, Location } from '../../types/testReporter';
|
import type { FullConfig, FullResult, Reporter, TestError, TestResult, TestStep, Location } from '../../types/testReporter';
|
||||||
import type { Suite, TestCase } from '../common/test';
|
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 { SuitePrivate } from '../../types/reporterPrivate';
|
||||||
import type { FullConfigInternal, FullProjectInternal } from '../common/types';
|
import type { FullConfigInternal, FullProjectInternal } from '../common/types';
|
||||||
import { createGuid } from 'playwright-core/lib/utils';
|
import { createGuid } from 'playwright-core/lib/utils';
|
||||||
|
|
@ -53,10 +53,16 @@ export class TeleReporterEmitter implements Reporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
onTestEnd(test: TestCase, result: TestResult): void {
|
onTestEnd(test: TestCase, result: TestResult): void {
|
||||||
|
const testEnd: JsonTestEnd = {
|
||||||
|
testId: test.id,
|
||||||
|
expectedStatus: test.expectedStatus,
|
||||||
|
annotations: test.annotations,
|
||||||
|
timeout: test.timeout,
|
||||||
|
};
|
||||||
this._messageSink({
|
this._messageSink({
|
||||||
method: 'onTestEnd',
|
method: 'onTestEnd',
|
||||||
params: {
|
params: {
|
||||||
testId: test.id,
|
test: testEnd,
|
||||||
result: this._serializeResultEnd(result),
|
result: this._serializeResultEnd(result),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -163,9 +169,6 @@ export class TeleReporterEmitter implements Reporter {
|
||||||
testId: test.id,
|
testId: test.id,
|
||||||
title: test.title,
|
title: test.title,
|
||||||
location: this._relativeLocation(test.location),
|
location: this._relativeLocation(test.location),
|
||||||
expectedStatus: test.expectedStatus,
|
|
||||||
timeout: test.timeout,
|
|
||||||
annotations: test.annotations,
|
|
||||||
retries: test.retries,
|
retries: test.retries,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -306,3 +306,27 @@ test('should show time', async ({ runUITest }) => {
|
||||||
|
|
||||||
await expect(page.getByTestId('status-line')).toHaveText('4/8 passed (50%)');
|
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%)');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue