UNPKG

@hazae41/phobos

Version:

Modern and minimalist testing library for the web

32 lines (30 loc) 607 B
/** * Check if a closure throws * @param closure closure to check * @returns true if the closure throwed */ function throws(closure) { try { closure(); return false; } catch (e) { return true; } } /** * Check if an async closure rejects (throws) * @param closure async closure to check * @returns a promise that returns true if the closure rejected */ async function rejects(closure) { try { await closure(); return false; } catch (e) { return true; } } export { rejects, throws }; //# sourceMappingURL=throws.mjs.map