Module

x/chai/lib/chai/utils/overwriteChainableMethod.js>overwriteChainableMethod

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
Latest
function overwriteChainableMethod
import { overwriteChainableMethod } from "https://dotland.deno.dev/x/chai@v5.1.2/lib/chai/utils/overwriteChainableMethod.js";

.overwriteChainableMethod(ctx, name, method, chainingBehavior)

Overwrites 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, 'lengthOf',
    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.lengthOf(3);
expect(myFoo).to.have.lengthOf.above(3);

Parameters

ctx

object whose method / property is to be overwritten

name

of method / property to overwrite

method

function that returns a function to be used for name

chainingBehavior

function that returns a function to be used for property