mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Simplify cleanup
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
bba18ba52b
commit
19943bf172
@ -55,14 +55,6 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis
|
|||||||
throw new Error(`Lens did not open the main window within ${timeout}ms`);
|
throw new Error(`Lens did not open the main window within ${timeout}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function closeApp(app: ElectronApplication, timeout = 30_000) {
|
|
||||||
// TODO: change once timeouts for the native function are available
|
|
||||||
await Promise.race([
|
|
||||||
app.evaluateHandle(({ app }) => app.quit()),
|
|
||||||
new Promise((r, reject) => setTimeout(() => reject(`Lens failed to quit within ${timeout}ms`), timeout)),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function start() {
|
export async function start() {
|
||||||
const CICD = path.join(os.tmpdir(), "lens-integration-testing", uuid.v4());
|
const CICD = path.join(os.tmpdir(), "lens-integration-testing", uuid.v4());
|
||||||
|
|
||||||
@ -85,15 +77,12 @@ export async function start() {
|
|||||||
app,
|
app,
|
||||||
window,
|
window,
|
||||||
cleanup: async () => {
|
cleanup: async () => {
|
||||||
try {
|
await app.evaluateHandle(({ app }) => app.quit());
|
||||||
await window.close();
|
|
||||||
} catch {}
|
|
||||||
await closeApp(app);
|
|
||||||
await remove(CICD);
|
await remove(CICD);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await closeApp(app);
|
await app.evaluateHandle(({ app }) => app.quit());
|
||||||
await remove(CICD);
|
await remove(CICD);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user