1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-03 18:50:05 +00:00
Files
adapter/sasjs-tests/src/utils/Assert.ts
2022-06-20 19:48:42 +03:00

23 lines
423 B
TypeScript

export const assert = (
expression: boolean | (() => boolean),
message = 'Assertion failed'
) => {
let result
try {
if (typeof expression === 'boolean') {
result = expression
} else {
result = expression()
}
} catch (e: any) {
console.error(message)
throw new Error(message)
}
if (!!result) {
return
} else {
console.error(message)
throw new Error(message)
}
}