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

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

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

.addProperty(ctx, name, getter)

Adds a property to the prototype of an object.

utils.addProperty(chai.Assertion.prototype, 'foo', function () {
    var obj = utils.flag(this, 'object');
    new chai.Assertion(obj).to.be.instanceof(Foo);
});

Can also be accessed directly from chai.Assertion.

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

Then can be used as any other assertion.

expect(myFoo).to.be.foo;

Parameters

ctx

object to which the property is added

name

of property to add

getter

function to be used for name