mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix integration test lifecycle fuctions not failing tests (#2259)
This commit is contained in:
parent
eec0644667
commit
8eb8fb6234
@ -13,7 +13,6 @@ import * as utils from "../helpers/utils";
|
|||||||
import { listHelmRepositories } from "../helpers/utils";
|
import { listHelmRepositories } from "../helpers/utils";
|
||||||
import { fail } from "assert";
|
import { fail } from "assert";
|
||||||
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
||||||
@ -21,9 +20,11 @@ describe("Lens integration tests", () => {
|
|||||||
let app: Application;
|
let app: Application;
|
||||||
|
|
||||||
describe("app start", () => {
|
describe("app start", () => {
|
||||||
beforeAll(async () => app = await utils.appStart(), 20000);
|
utils.beforeAllWrapped(async () => {
|
||||||
|
app = await utils.appStart();
|
||||||
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
await utils.tearDown(app);
|
await utils.tearDown(app);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,10 +33,12 @@ describe("Lens cluster pages", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe("cluster add", () => {
|
describe("cluster add", () => {
|
||||||
beforeAll(async () => app = await utils.appStart(), 20000);
|
utils.beforeAllWrapped(async () => {
|
||||||
|
app = await utils.appStart();
|
||||||
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app && app.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -64,11 +66,10 @@ describe("Lens cluster pages", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("cluster pages", () => {
|
describe("cluster pages", () => {
|
||||||
|
utils.beforeAllWrapped(appStartAddCluster);
|
||||||
|
|
||||||
beforeAll(appStartAddCluster, 40000);
|
utils.afterAllWrapped(async () => {
|
||||||
|
if (app?.isRunning()) {
|
||||||
afterAll(async () => {
|
|
||||||
if (app && app.isRunning()) {
|
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -355,10 +356,10 @@ describe("Lens cluster pages", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("viewing pod logs", () => {
|
describe("viewing pod logs", () => {
|
||||||
beforeEach(appStartAddCluster, 40000);
|
utils.beforeEachWrapped(appStartAddCluster);
|
||||||
|
|
||||||
afterEach(async () => {
|
utils.afterEachWrapped(async () => {
|
||||||
if (app && app.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -405,10 +406,10 @@ describe("Lens cluster pages", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("cluster operations", () => {
|
describe("cluster operations", () => {
|
||||||
beforeEach(appStartAddCluster, 40000);
|
utils.beforeEachWrapped(appStartAddCluster);
|
||||||
|
|
||||||
afterEach(async () => {
|
utils.afterEachWrapped(async () => {
|
||||||
if (app && app.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,9 +7,11 @@ describe("Lens command palette", () => {
|
|||||||
let app: Application;
|
let app: Application;
|
||||||
|
|
||||||
describe("menu", () => {
|
describe("menu", () => {
|
||||||
beforeAll(async () => app = await utils.appStart(), 20000);
|
utils.beforeAllWrapped(async () => {
|
||||||
|
app = await utils.appStart();
|
||||||
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
await utils.tearDown(app);
|
await utils.tearDown(app);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,13 +13,13 @@ describe("Lens integration tests", () => {
|
|||||||
const ready = minikubeReady("workspace-int-tests");
|
const ready = minikubeReady("workspace-int-tests");
|
||||||
|
|
||||||
utils.describeIf(ready)("workspaces", () => {
|
utils.describeIf(ready)("workspaces", () => {
|
||||||
beforeAll(async () => {
|
utils.beforeAllWrapped(async () => {
|
||||||
app = await utils.appStart();
|
app = await utils.appStart();
|
||||||
await utils.clickWhatsNew(app);
|
await utils.clickWhatsNew(app);
|
||||||
}, 20000);
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app && app.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,6 +8,39 @@ const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
|
|||||||
"darwin": "./dist/mac/Lens.app/Contents/MacOS/Lens",
|
"darwin": "./dist/mac/Lens.app/Contents/MacOS/Lens",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface DoneCallback {
|
||||||
|
(...args: any[]): any;
|
||||||
|
fail(error?: string | { message: string }): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is necessary because Jest doesn't do this correctly.
|
||||||
|
* @param fn The function to call
|
||||||
|
*/
|
||||||
|
export function wrapJestLifecycle(fn: () => Promise<void>): (done: DoneCallback) => void {
|
||||||
|
return function (done: DoneCallback) {
|
||||||
|
fn()
|
||||||
|
.then(() => done())
|
||||||
|
.catch(error => done.fail(error));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function beforeAllWrapped(fn: () => Promise<void>): void {
|
||||||
|
beforeAll(wrapJestLifecycle(fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function beforeEachWrapped(fn: () => Promise<void>): void {
|
||||||
|
beforeEach(wrapJestLifecycle(fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function afterAllWrapped(fn: () => Promise<void>): void {
|
||||||
|
afterAll(wrapJestLifecycle(fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function afterEachWrapped(fn: () => Promise<void>): void {
|
||||||
|
afterEach(wrapJestLifecycle(fn));
|
||||||
|
}
|
||||||
|
|
||||||
export function itIf(condition: boolean) {
|
export function itIf(condition: boolean) {
|
||||||
return condition ? it : it.skip;
|
return condition ? it : it.skip;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user