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: clear previous test results optionally (#22224)
Yury Semikhatskyfc23d3569796
diff --git a/packages/playwright-test/src/isomorphic/teleReceiver.ts b/packages/playwright-test/src/isomorphic/teleReceiver.tsindex df3350f408..8d9dd86bfe 100644--- a/packages/playwright-test/src/isomorphic/teleReceiver.ts+++ b/packages/playwright-test/src/isomorphic/teleReceiver.ts@@ -118,6 +118,7 @@ export class TeleReporterReceiver {private _reporter: Reporter;private _tests = new Map<string, TeleTestCase>();private _rootDir!: string;+ private _clearPreviousResultsWhenTestBegins: boolean = false;constructor(pathSeparator: string, reporter: Reporter) {this._rootSuite = new TeleSuite('', 'root');@@ -161,6 +162,10 @@ export class TeleReporterReceiver {return this._onExit();}+ _setClearPreviousResultsWhenTestBegins() {+ this._clearPreviousResultsWhenTestBegins = true;+ }+private _onBegin(config: JsonConfig, projects: JsonProject[]) {this._rootDir = config.rootDir;for (const project of projects) {@@ -196,6 +201,8 @@ export class TeleReporterReceiver {private _onTestBegin(testId: string, payload: JsonTestResultStart) {const test = this._tests.get(testId)!;+ if (this._clearPreviousResultsWhenTestBegins)+ test._clearResults();const testResult = test._createTestResult(payload.id);testResult.retry = payload.retry;testResult.workerIndex = payload.workerIndex;@@ -450,7 +457,6 @@ export class TeleTestCase implements reporterTypes.TestCase {}_createTestResult(id: string): TeleTestResult {- this._clearResults();const result: TeleTestResult = {retry: this.results.length,parallelIndex: -1,diff --git a/packages/trace-viewer/src/ui/watchMode.tsx b/packages/trace-viewer/src/ui/watchMode.tsxindex 6ecbb68fe9..0a2af21cdc 100644--- a/packages/trace-viewer/src/ui/watchMode.tsx+++ b/packages/trace-viewer/src/ui/watchMode.tsx@@ -129,8 +129,10 @@ export const WatchModeView: React.FC<{}> = ({// Clear test results.{for (const test of testModel.rootSuite?.allTests() || []) {- if (testIds.has(test.id))+ if (testIds.has(test.id)) {+ (test as TeleTestCase)._clearResults();(test as TeleTestCase)._createTestResult('pending');+ }}setTestModel({ ...testModel });}@@ -594,6 +596,7 @@ const refreshRootSuite = (eraseResults: boolean): Promise<void> => {xtermDataSource.write((error.stack || error.value || '') + '\n');},});+ receiver._setClearPreviousResultsWhenTestBegins();return sendMessage('list', {});};