-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Assert an increase/decrease by an amount (delta) #339
Comments
The former is closer to the rest of the syntax in chai. In my opinion we should always aim for tests to be human readable, and the 5 in the second set just seem like magic numbers. I see some discussion about how it is uncomfortably generic, but if you really think about other assertions I can't think of a way for the |
both @matthijsgroen's chai-changes and chai-change (disclaimer: mine) plugins support this, along with async assertions (promises in Matthijs' and callbacks in mine). I guess the change of maintainer explains why the changes feature didn't land in 2013 in #218, I'm not bitter ;) |
Hey @timruffles, sorry about the overlap - wasn't aware of either of these plugins at the time of merging the original PR. As you ant @matthijsgroen both have plugins which cater for this - do you have any input on this issue? Even if that input is "don't do it" 😄. |
I really like the If I was to make a suggestion, it's that the current implementation in core doesn't support async use-cases, or functional style: e.g the below - which is bread and butter node webdev - isn't possible in the current implementation: it('creates a version', function(done) {
assert.change(function(cb) {
create({
type: "plan",
name: "v2",
}, cb)
}, function(cb) {
Version.count({}, cb);
}, {
callback: done, by: 1,
});
}); |
https://github.com/matthijsgroen/chai-changes#changebydelta The changes library supports async, automatically if the return value of the |
+1 for the Also, I can't think of a better way to implement it other than having an assertion just for it. |
Well, as I've said a few times before - I'm here as a steward, not a dictator. So if people want PRs welcome 😄 |
Hi, @keithamus, how are you? PS.: I hope I'm not bothering you, feel free to answer whenever you want 😃 |
Feel free to make a PR for this @lucasfcosta. You're not bothering me, its amazing to have such a good contributor eager to contribute more! |
I think we can close this one, @keithamus ! |
As per #333 and #330, we should be able to assert on the delta of a
.changed
/.increased
/.decreased
.So far (in #333) the proposed syntaxes are:
or
/cc @oveddan @cmpolis @logicalparadox
The text was updated successfully, but these errors were encountered: