Skip to content

Instantly share code, notes, and snippets.

@c4urself
Created January 3, 2013 18:17
Show Gist options
  • Save c4urself/4445562 to your computer and use it in GitHub Desktop.
Save c4urself/4445562 to your computer and use it in GitHub Desktop.
Chai doesn't play nice with JS Lint's check for incorrect use of `false` and `true` -- a setting that cannot be turned off via JS Lint options. The addition of `_true` and `_false` properties to Chai fixes this making JS Lint work correctly.
// We're providing some convenience functions here as well as making sure
// chai tests don't fall on jshint errors by remapping true/false properties
chai.Assertion.addProperty('_true', function () {
this.assert(
true === this.__flags.object,
'expected #{this} to be true',
'expected #{this} to be false',
this.negate ? false : true
);
});
chai.Assertion.addProperty('_false', function () {
this.assert(
false === this.__flags.object,
'expected #{this} to be false',
'expected #{this} to be true',
this.negate ? true : false
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment