Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

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

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

.addMethod(ctx, name, method)

Adds a method to the prototype of an object.

utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
    var obj = utils.flag(this, 'object');
    new chai.Assertion(obj).to.be.equal(str);
});

Can also be accessed directly from chai.Assertion.

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

Then can be used as any other assertion.

expect(fooStr).to.be.foo('bar');

Parameters

ctx

object to which the method is added

name

of method to add

method

function to be used for name