相关疑难解决方法(0)

有没有办法在自定义匹配器中使用Jasmine默认匹配器?

我在一些形式的Jasmine测试规范中有一个自定义匹配器:

this.addMatchers({
    checkContains: function(elem){
        var found = false;
        $.each( this.actual, function( actualItem ){

            // Check if these objects contain the same properties.
            found = found || actualItem.thing == elem;
        });
        return found;
    }
});
Run Code Online (Sandbox Code Playgroud)

当然,actualItem.thing == elem实际上并没有比较对象内容 - 我必须在JavaScript中使用对象比较中的一个更复杂的解决方案.

不过,我不禁注意到,Jasmine已经有了一个很好的对象相等检查器:expect(x).toEqual(y).有没有办法在自定义匹配器中使用它?有没有在自定义匹配器中使用匹配器的一般方法?

javascript unit-testing matcher jasmine

9
推荐指数
1
解决办法
2770
查看次数

标签 统计

jasmine ×1

javascript ×1

matcher ×1

unit-testing ×1