UNPKG

@hazae41/phobos

Version:

Modern and minimalist testing library for the web

35 lines (32 loc) 646 B
'use strict'; /** * 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; } } exports.rejects = rejects; exports.throws = throws; //# sourceMappingURL=throws.cjs.map