jasmine Custom Matchers Adding Custom Matchers


Example

Custom matchers can be added in jasmine using the syntax:

jasmine.addMatchers([
    toMatch: function () {
    return {
        compare: function (actual, expected) {
            return {
                pass: actual===expected,
                message: "Expected actual to match expected
            }
        }
    }
}
]);

This matcher can now be called with:

expected(actual).toMatch(expected);