Namespace: overwriteChainableMethod

overwriteChainableMethod

overwriteChainableMethod (ctx, name, method, chainingBehavior)

Overwites an already existing chainable method and provides access to the previous function or property. Must return functions to be used for name.

utils.overwriteChainableMethod(chai.Assertion.prototype, 'length',
  function (_super) {
  }
, function (_super) {
  }
);

Can also be accessed directly from chai.Assertion.

chai.Assertion.overwriteChainableMethod('foo', fn, fn);

Then can be used as any other assertion.

expect(myFoo).to.have.length(3);
expect(myFoo).to.have.length.above(3);
Source: