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
- 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:
1 parent
4f74b9aabe
commit
2e38938331
5 files changed
+48
-26
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user