Skip to content

Commit

Permalink
fix: added test status into deleteWorkspaceOnTestFail method
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <mdolhalo@redhat.com>
  • Loading branch information
mdolhalo authored and dmytro-ndp committed Jul 7, 2023
1 parent aba2a0e commit 27e839c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/e2e/specs/MochaHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ exports.mochaHooks = {
}
},
],
afterAll: [
afterEach: [
// stop and remove running workspace
async () => {
if (BaseTestConstants.DELETE_WORKSPACE_ON_FAILED_TEST) {
Logger.info('Property DELETE_WORKSPACE_ON_FAILED_TEST is true - trying to stop and delete running workspace with API.');
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(latestWorkspace);
async function (this: Mocha.Context): Promise<void> {
if (this.currentTest?.state === 'failed') {
if (BaseTestConstants.DELETE_WORKSPACE_ON_FAILED_TEST) {
Logger.info('Property DELETE_WORKSPACE_ON_FAILED_TEST is true - trying to stop and delete running workspace with API.');
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(latestWorkspace);
}
}
},
],
afterAll: [
async function stopTheDriver(): Promise<void> {
if (!BaseTestConstants.TS_DEBUG_MODE && ChromeDriverConstants.TS_USE_WEB_DRIVER_FOR_TEST) {
await driverHelper.getDriver().quit();
Expand Down

0 comments on commit 27e839c

Please sign in to comment.