-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make must
extensible
#24
Comments
Hey! I'm with you. Allowing extensibility is most sensible. We might need to provide a function or two to ease asserting and throwing an error to simplify creating custom matchers. Internally I added a function for that at Line 995 in d09d368
Also, I'm not 100% sure does Must need to know when its being extended[1] vs just allowing extensions to do whatever they please[2]. Something like a promise plugin could just be called last and it would iterate over existing matcher functions to wrap them for promise support.
|
@moll ... I'm open to either solution. I completely agree that Which ever solution you decide, I'll be glad to pitch in. :-) Already have a few plugins in mind, so I hope this lands soon! |
@moll, I create a simple proof of concept at JohnnyEstilles/must-promise. Let me know what you think. |
@moll, updated my proof of concept with some additional matchers. Let me know what you think. |
Hey, I pondered over the Line 1028 in 77616e8
In short, it works like any assert function ever: Must.prototype.truthy = function() {
this.assert(this.actual, "be truthy")
} Given an object with Must.prototype.null = function() {
this.assert(this.actual === null, "be", {expected: null})
} If you give a function instead of a string, that function will be called for the message should the assertion fail. You can still pass So, give me a call and-or reply here when you get around to it. Thanks! |
Let's continue this conversation over at #12. |
Allow
must
to be extended using community developed assertion/matcher plugins. This would allow for consumers to easily add either their own or community provided matchers, without bloating themust
core library. We could easily add assertions for promises (see issue #22), Express request/response objects, etc.I propose using the typical
.use()
syntax. For example:... or something similar.
The text was updated successfully, but these errors were encountered: