有没有办法向chai的assert接口添加自定义方法?
我尝试过以下代码:
我尝试过以下代码:
// test-helper.js
export const testPlugin = function(chai) {
chai.Assertion.addMethod('customMethod', function() {
//Something
})
}
// abc.test.js
import {assert, use} from 'chai'
import {testPlugin} from 'test-helper.js'
use(testPlugin)
但我认为这只适用于chai的expect接口。
我想使用自定义方法,如assert.customMethod(actual, expected)
如果我漏掉了什么,请告诉我。