此最小示例自定义chai断言应该失败。它不是。是什么使它失败了?
const chai = require('chai');
chai.Assertion.addMethod('test1', function() {
this.assert(
false,
"Failed",
"Failed",
"foo",
"bar"
);
});
chai.expect({}).to.be.test1;
最佳答案
必须调用test1。如:chai.expect({}).to.be.test1();
关于javascript - 如何使Chai自定义断言失败?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56139320/