to-have-property
jasmine · javascript · matcher · unit testing

toHaveProperty npm Build Status

toHaveProperty matcher for Jasmine (http://jasmine.github.io/) to check whether object has property or not.

Installation

npm install to-have-property --save-dev

How to use


require('to-have-property');

it('should find property in object', function() {
    expect({ x: 10 }).toHaveProperty('x');
});

it('should find property in object and check is it equal to certain value', function() {
    expect({ y: 123}).toHaveProperty('y', 123);
});

it('should find properties in object and check are they equal to values', function() {
    expect({ x: 1, y: 2, z: 3}).toHaveProperties({'x': 1, 'y': 2});
});

it('should find all properties in object', function() {
    expect({ x: 1, y: 2, z: 3 }).toHaveProperties('x', 'y');
});

More

others Jasmine matchers and extensions