有没有办法添加自定义方法来断言 chai 的接口?
我试过:
// 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)
Run Code Online (Sandbox Code Playgroud)
但我认为这只适用于 chai 的 expect 接口。我想使用这个自定义方法作为assert.customMethod(actual, expected)
如果我在这里遗漏了什么,请告诉我。