消極匹配

使用 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"
                }
            }
        }
    }