消极匹配

使用 not 时,自定义匹配器的传递值将被取消。自定义匹配器可以使用负比较属性来显式处理需要否定的情况:

toMatch: function () {
        return {
            compare: function (actual, expected) {
                return {
                    pass: actual===expected,
                    message: "Expected actual to match expected"
                }
            },
            negativeCompare: function(actual, expected){
                return {
                    pass: actual!==expected,
                    message: "Expected actual not to match expected"
                }
            }
        }
    }