chore: clear previous test results optionally (#22224)
This commit is contained in:
parent
13c7ddb883
commit
fc23d35697
|
|
@ -118,6 +118,7 @@ export class TeleReporterReceiver {
|
||||||
private _reporter: Reporter;
|
private _reporter: Reporter;
|
||||||
private _tests = new Map<string, TeleTestCase>();
|
private _tests = new Map<string, TeleTestCase>();
|
||||||
private _rootDir!: string;
|
private _rootDir!: string;
|
||||||
|
private _clearPreviousResultsWhenTestBegins: boolean = false;
|
||||||
|
|
||||||
constructor(pathSeparator: string, reporter: Reporter) {
|
constructor(pathSeparator: string, reporter: Reporter) {
|
||||||
this._rootSuite = new TeleSuite('', 'root');
|
this._rootSuite = new TeleSuite('', 'root');
|
||||||
|
|
@ -161,6 +162,10 @@ export class TeleReporterReceiver {
|
||||||
return this._onExit();
|
return this._onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setClearPreviousResultsWhenTestBegins() {
|
||||||
|
this._clearPreviousResultsWhenTestBegins = true;
|
||||||
|
}
|
||||||
|
|
||||||
private _onBegin(config: JsonConfig, projects: JsonProject[]) {
|
private _onBegin(config: JsonConfig, projects: JsonProject[]) {
|
||||||
this._rootDir = config.rootDir;
|
this._rootDir = config.rootDir;
|
||||||
for (const project of projects) {
|
for (const project of projects) {
|
||||||
|
|
@ -196,6 +201,8 @@ export class TeleReporterReceiver {
|
||||||
|
|
||||||
private _onTestBegin(testId: string, payload: JsonTestResultStart) {
|
private _onTestBegin(testId: string, payload: JsonTestResultStart) {
|
||||||
const test = this._tests.get(testId)!;
|
const test = this._tests.get(testId)!;
|
||||||
|
if (this._clearPreviousResultsWhenTestBegins)
|
||||||
|
test._clearResults();
|
||||||
const testResult = test._createTestResult(payload.id);
|
const testResult = test._createTestResult(payload.id);
|
||||||
testResult.retry = payload.retry;
|
testResult.retry = payload.retry;
|
||||||
testResult.workerIndex = payload.workerIndex;
|
testResult.workerIndex = payload.workerIndex;
|
||||||
|
|
@ -450,7 +457,6 @@ export class TeleTestCase implements reporterTypes.TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createTestResult(id: string): TeleTestResult {
|
_createTestResult(id: string): TeleTestResult {
|
||||||
this._clearResults();
|
|
||||||
const result: TeleTestResult = {
|
const result: TeleTestResult = {
|
||||||
retry: this.results.length,
|
retry: this.results.length,
|
||||||
parallelIndex: -1,
|
parallelIndex: -1,
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,10 @@ export const WatchModeView: React.FC<{}> = ({
|
||||||
// Clear test results.
|
// Clear test results.
|
||||||
{
|
{
|
||||||
for (const test of testModel.rootSuite?.allTests() || []) {
|
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');
|
(test as TeleTestCase)._createTestResult('pending');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setTestModel({ ...testModel });
|
setTestModel({ ...testModel });
|
||||||
}
|
}
|
||||||
|
|
@ -594,6 +596,7 @@ const refreshRootSuite = (eraseResults: boolean): Promise<void> => {
|
||||||
xtermDataSource.write((error.stack || error.value || '') + '\n');
|
xtermDataSource.write((error.stack || error.value || '') + '\n');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
receiver._setClearPreviousResultsWhenTestBegins();
|
||||||
return sendMessage('list', {});
|
return sendMessage('list', {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue