diff --git a/integration/__tests__/app.tests.ts b/integration/__tests__/app.tests.ts index d1f3b54616..97a03ab615 100644 --- a/integration/__tests__/app.tests.ts +++ b/integration/__tests__/app.tests.ts @@ -10,15 +10,15 @@ describe("Lens integration tests", () => { let app: Application; describe("app start", () => { - beforeAll(utils.wrapJestLifecycle(async () => { + utils.beforeAllWrapped(async () => { app = await utils.appStart(); - })); + }); - afterAll(utils.wrapJestLifecycle(async () => { + utils.afterAllWrapped(async () => { if (app?.isRunning()) { await utils.tearDown(app); } - })); + }); it('shows "whats new"', async () => { await utils.clickWhatsNew(app); diff --git a/integration/__tests__/cluster-pages.tests.ts b/integration/__tests__/cluster-pages.tests.ts index a56f71d1b8..1329f1920d 100644 --- a/integration/__tests__/cluster-pages.tests.ts +++ b/integration/__tests__/cluster-pages.tests.ts @@ -32,15 +32,15 @@ describe("Lens cluster pages", () => { }; describe("cluster add", () => { - beforeAll(utils.wrapJestLifecycle(async () => { + utils.beforeAllWrapped(async () => { app = await utils.appStart(); - })); + }); - afterAll(utils.wrapJestLifecycle(async () => { - if (app && app.isRunning()) { + utils.afterAllWrapped(async () => { + if (app?.isRunning()) { return utils.tearDown(app); } - })); + }); it("allows to add a cluster", async () => { await addCluster(); @@ -56,14 +56,13 @@ describe("Lens cluster pages", () => { }; describe("cluster pages", () => { + utils.beforeAllWrapped(appStartAddCluster); - beforeAll(utils.wrapJestLifecycle(appStartAddCluster)); - - afterAll(utils.wrapJestLifecycle(async () => { - if (app && app.isRunning()) { + utils.afterAllWrapped(async () => { + if (app?.isRunning()) { return utils.tearDown(app); } - })); + }); const tests: { drawer?: string @@ -339,13 +338,13 @@ describe("Lens cluster pages", () => { }); describe("viewing pod logs", () => { - beforeEach(utils.wrapJestLifecycle(appStartAddCluster)); + utils.beforeEachWrapped(appStartAddCluster); - afterEach(utils.wrapJestLifecycle(async () => { + utils.afterEachWrapped(async () => { if (app?.isRunning()) { return utils.tearDown(app); } - })); + }); it(`shows a logs for a pod`, async () => { expect(clusterAdded).toBe(true); @@ -389,13 +388,13 @@ describe("Lens cluster pages", () => { }); describe("cluster operations", () => { - beforeEach(utils.wrapJestLifecycle(appStartAddCluster)); + utils.beforeEachWrapped(appStartAddCluster); - afterEach(utils.wrapJestLifecycle(async () => { + utils.afterEachWrapped(async () => { if (app?.isRunning()) { return utils.tearDown(app); } - })); + }); it("shows default namespace", async () => { expect(clusterAdded).toBe(true); diff --git a/integration/__tests__/command-palette.tests.ts b/integration/__tests__/command-palette.tests.ts index 86aa469656..08da064bd2 100644 --- a/integration/__tests__/command-palette.tests.ts +++ b/integration/__tests__/command-palette.tests.ts @@ -7,15 +7,15 @@ describe("Lens command palette", () => { let app: Application; describe("menu", () => { - beforeAll(utils.wrapJestLifecycle(async () => { + utils.beforeAllWrapped(async () => { app = await utils.appStart(); - })); + }); - afterAll(utils.wrapJestLifecycle(async () => { + utils.afterAllWrapped(async () => { if (app?.isRunning()) { await utils.tearDown(app); } - })); + }); it("opens command dialog from menu", async () => { await utils.clickWhatsNew(app); diff --git a/integration/__tests__/workspace.tests.ts b/integration/__tests__/workspace.tests.ts index fd1a0ef15c..6ad56d5255 100644 --- a/integration/__tests__/workspace.tests.ts +++ b/integration/__tests__/workspace.tests.ts @@ -13,16 +13,16 @@ describe("Lens integration tests", () => { const ready = minikubeReady("workspace-int-tests"); utils.describeIf(ready)("workspaces", () => { - beforeAll(utils.wrapJestLifecycle(async () => { + utils.beforeAllWrapped(async () => { app = await utils.appStart(); await utils.clickWhatsNew(app); - })); + }); - afterAll(utils.wrapJestLifecycle(async () => { + utils.afterAllWrapped(async () => { if (app?.isRunning()) { return utils.tearDown(app); } - })); + }); const switchToWorkspace = async (name: string) => { await app.client.click("[data-test-id=current-workspace]"); diff --git a/integration/helpers/utils.ts b/integration/helpers/utils.ts index a79885d0f6..ad4da8e8c3 100644 --- a/integration/helpers/utils.ts +++ b/integration/helpers/utils.ts @@ -25,6 +25,22 @@ export function wrapJestLifecycle(fn: () => Promise): (done: DoneCallback) }; } +export function beforeAllWrapped(fn: () => Promise): void { + beforeAll(wrapJestLifecycle(fn)); +} + +export function beforeEachWrapped(fn: () => Promise): void { + beforeEach(wrapJestLifecycle(fn)); +} + +export function afterAllWrapped(fn: () => Promise): void { + afterAll(wrapJestLifecycle(fn)); +} + +export function afterEachWrapped(fn: () => Promise): void { + afterEach(wrapJestLifecycle(fn)); +} + export function itIf(condition: boolean) { return condition ? it : it.skip; }