platformService tests and move tests from tdd to bdd (#13131)

This commit is contained in:
Arvind Ranasaria
2020-11-03 13:34:33 -08:00
committed by GitHub
parent 64510506e8
commit f10ac10f6d
12 changed files with 355 additions and 97 deletions

View File

@@ -53,3 +53,12 @@ export function throwUnless(condition: boolean, message?: string): asserts condi
throw new Error(message);
}
}
export async function tryExecuteAction<T>(action: () => T | PromiseLike<T>): Promise<{ result: T | undefined, error: any }> {
let error: any, result: T | undefined;
try {
result = await action();
} catch (e) {
error = e;
}
return { result, error };
}