Fix integration test lifecycle fuctions not failing tests

- Fail test if an async lifecycle function fails (though a bug in Jest
  means that the test body is still run)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2021-03-01 12:12:35 -05:00
1 parent 4f74b9aabe
commit 2e38938331
5 files changed
+48 -26

No files matched your search

+17
View File
@@ -8,6 +8,23 @@ const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
"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 itIf(condition: boolean) {
return condition ? it : it.skip;
}