chaijs.github.io icon indicating copy to clipboard operation
chaijs.github.io copied to clipboard

Helper example won't run as is

Open jlaurens opened this issue 5 years ago • 0 comments

The helpers page reads

Assertion.overwriteMethod('above', function (_super) {
  return function assertAge (n) {
    if (utils.flag(this, 'model.age')) {
       [...]

      // next, make sure we have an age
      new Assertion(obj).to.have.deep.property('_attrs.age').a('number'); //<<<< ERROR

      // now we compare
      [...]
  };
});

The assertion always fails because '_attrs.age' is not a valid property name.

If you do not want to remove it, simply replace it by

      new Assertion(obj._attrs).to.have.property('age').a('number');

jlaurens avatar Oct 07 '20 18:10 jlaurens