import { overwriteMethod } from "https://dotland.deno.dev/x/chai@v5.1.2/lib/chai/utils/overwriteMethod.js";
.overwriteMethod(ctx, name, fn)
Overwrites an already existing method and provides access to previous function. Must return function to be used for name.
utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
return function (str) {
var obj = utils.flag(this, 'object');
if (obj instanceof Foo) {
new chai.Assertion(obj.value).to.equal(str);
} else {
_super.apply(this, arguments);
}
}
});
Can also be accessed directly from chai.Assertion
.
chai.Assertion.overwriteMethod('foo', fn);
Then can be used as any other assertion.
expect(myFoo).to.equal('bar');