chore(test): check test suite wide for failures (#8611)

* chore(test): check suite wide for failures before deleting traces
This commit is contained in:
Vladimir Lazar 2024-08-28 12:20:57 +03:00 committed by GitHub
parent 4ebb4bed5c
commit 56a39ffa5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View file

@ -43,6 +43,7 @@ export class PodmanDesktopRunner {
private _autoUpdate: boolean;
private _autoCheckUpdate: boolean;
private _testPassed: boolean;
private _suitePassed: boolean;
constructor({
profile = '',
@ -57,7 +58,8 @@ export class PodmanDesktopRunner {
this._videoAndTraceName = undefined;
this._autoUpdate = autoUpdate;
this._autoCheckUpdate = autoCheckUpdate;
this._testPassed = true;
this._testPassed = false;
this._suitePassed = true;
// Options setting always needs to be last action in constructor in order to apply settings correctly
this._options = this.defaultOptions();
@ -235,7 +237,7 @@ export class PodmanDesktopRunner {
rmSync(rawTracesPath, { recursive: true, force: true, maxRetries: 5 });
}
if (!this._testPassed || !this._videoAndTraceName) return;
if (!this._testPassed || !this._suitePassed || !this._videoAndTraceName) return;
if (!process.env.KEEP_TRACES_ON_PASS) {
const tracesPath = join(this._testOutput, 'traces', `${this._videoAndTraceName}_trace.zip`);
@ -348,6 +350,10 @@ export class PodmanDesktopRunner {
this._testPassed = value;
}
public setSuitePassed(value: boolean): void {
this._suitePassed = value;
}
public get options(): object {
return this._options;
}

View file

@ -41,4 +41,5 @@ export async function takeScreenshotHook(runner: PodmanDesktopRunner, taskName:
console.log(`Screenshot of the failed test will be saved to: ${fileName}`);
await runner.screenshot(`${fileName}.png`);
runner.setTestPassed(false);
runner.setSuitePassed(false);
}

View file

@ -16,10 +16,9 @@
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/
import { afterEach, beforeEach, onTestFailed, onTestFinished } from 'vitest';
import { afterEach, beforeEach, onTestFailed } from 'vitest';
import type { RunnerTestContext } from '../testContext/runner-test-context';
import { checkForFailedTest } from '../utility/operations';
import { takeScreenshotHook } from './extended-hooks-utils';
afterEach(async (context: RunnerTestContext) => {
@ -27,5 +26,5 @@ afterEach(async (context: RunnerTestContext) => {
});
beforeEach(async (context: RunnerTestContext) => {
onTestFinished(results => checkForFailedTest(results, context.pdRunner));
context?.pdRunner?.setTestPassed(true);
});