diff --git a/packages/util-waiter/src/utils/validate.spec.ts b/packages/util-waiter/src/utils/validate.spec.ts index e8bd7e335447f..bff31c85656b8 100644 --- a/packages/util-waiter/src/utils/validate.spec.ts +++ b/packages/util-waiter/src/utils/validate.spec.ts @@ -34,8 +34,8 @@ describe(validateWaiterOptions.name, () => { validateWaiterOptions(waiterOptions); expect(1).toBe("SHOULD NOT GET HERE"); } catch (e) { - expect(e).toBe( - "WaiterConfiguration.maxDelay [120] must be greater than WaiterConfiguration.minDelay [200] for this waiter" + expect(e.toString()).toBe( + "Error: WaiterConfiguration.maxDelay [120] must be greater than WaiterConfiguration.minDelay [200] for this waiter" ); done(); } @@ -59,7 +59,7 @@ describe(validateWaiterOptions.name, () => { try { validateWaiterOptions(waiterOptions); } catch (e) { - expect(e).toBe("WaiterConfiguration.maxWaitTime must be greater than 0"); + expect(e.toString()).toBe("Error: WaiterConfiguration.maxWaitTime must be greater than 0"); done(); } }); @@ -70,8 +70,8 @@ describe(validateWaiterOptions.name, () => { try { validateWaiterOptions(waiterOptions); } catch (e) { - expect(e).toBe( - "WaiterConfiguration.maxWaitTime [150] must be greater than WaiterConfiguration.minDelay [200] for this waiter" + expect(e.toString()).toBe( + "Error: WaiterConfiguration.maxWaitTime [150] must be greater than WaiterConfiguration.minDelay [200] for this waiter" ); done(); } @@ -83,8 +83,8 @@ describe(validateWaiterOptions.name, () => { try { validateWaiterOptions(waiterOptions); } catch (e) { - expect(e).toBe( - "WaiterConfiguration.maxWaitTime [200] must be greater than WaiterConfiguration.minDelay [200] for this waiter" + expect(e.toString()).toBe( + "Error: WaiterConfiguration.maxWaitTime [200] must be greater than WaiterConfiguration.minDelay [200] for this waiter" ); } }); diff --git a/packages/util-waiter/src/utils/validate.ts b/packages/util-waiter/src/utils/validate.ts index 49644886e3dd4..c186d67fe38c9 100644 --- a/packages/util-waiter/src/utils/validate.ts +++ b/packages/util-waiter/src/utils/validate.ts @@ -6,14 +6,18 @@ import { WaiterOptions } from "../waiter"; */ export const validateWaiterOptions = (options: WaiterOptions): void => { if (options.maxWaitTime < 1) { - throw `WaiterConfiguration.maxWaitTime must be greater than 0`; + throw new Error(`WaiterConfiguration.maxWaitTime must be greater than 0`); } else if (options.minDelay < 1) { - throw `WaiterConfiguration.minDelay must be greater than 0`; + throw new Error(`WaiterConfiguration.minDelay must be greater than 0`); } else if (options.maxDelay < 1) { - throw `WaiterConfiguration.maxDelay must be greater than 0`; + throw new Error(`WaiterConfiguration.maxDelay must be greater than 0`); } else if (options.maxWaitTime <= options.minDelay) { - throw `WaiterConfiguration.maxWaitTime [${options.maxWaitTime}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter`; + throw new Error( + `WaiterConfiguration.maxWaitTime [${options.maxWaitTime}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter` + ); } else if (options.maxDelay < options.minDelay) { - throw `WaiterConfiguration.maxDelay [${options.maxDelay}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter`; + throw new Error( + `WaiterConfiguration.maxDelay [${options.maxDelay}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter` + ); } };