chore: clear previous test results optionally (#22224)

This commit is contained in:
Yury Semikhatsky 2023-04-06 08:33:17 -07:00 committed by GitHub
parent 13c7ddb883
commit fc23d35697
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -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,

View file

@ -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', {});
};