chaijs/chai — pull request #218 by timruffles (2013-11-30 15:48:25+00:00)
Title: add change assertion - enforce a change to a value

Hi - initial pull request to see what people think of a change assertion. It's useful to avoid false positives where a test that previously caused an effect doesn't any longer, but this failure is masked by something else having caused it.

addUser();
assert.equal(users.length,1);

This is prone to false positives: if we break `addUser()` and merge it into a branch where `users` started with a default user, we'd not get a failing test. With a change assertion we can be more specific about the change we want to see:

assert.change(function() { return users.length},addUser,{by: 1});

Would avoid this issue.