must
Version:
Testing and assertion library with friendly BDD syntax — awesome.must.be.true(). Many expressive matchers and is test runner and framework agnostic. Follows RFC 2119 with its use of MUST. Good and well tested stuff.
18 lines (14 loc) • 489 B
JavaScript
var AssertionError = require("./assertion_error")
var Thenable = require("./thenable")
var then = Thenable.prototype.then
module.exports = function(must) {
return Thenable(must, promisify)
}
function promisify(fn) {
return function matcher() {
var must = Object.create(this)
if (Error.captureStackTrace) Error.captureStackTrace(must, matcher)
return this.actual.then(raise, then.bind(must, fn, arguments))
}
}
function raise() { throw new AssertionError("Resolved") }