如何在Botium绑定完成后运行其他断言?
const bb = new BotiumBindings({ convodirs: ['/spec'] })
BotiumBindings.helper.mocha().setupMochaTestSuite({ bb })
// TODO: GET request to an external API.
答案 0 :(得分:1)
向Botium添加自定义断言逻辑的推荐方法是向Botium添加自己的断言模块。您可以找到详细信息here,但总之:
module.exports = class CustomAsserter {
constructor (context, caps, globalArgs) {
this.context = context
this.caps = caps
this.globalArgs = globalArgs
}
assertConvoStep ({convo, convoStep, args, isGlobal, botMsg}) {
if (botMsg.message !== 'hugo') throw new Error('expected hugo')
return Promise.resolve()
}
}
{
"botium": {
"Capabilities": {
...
"ASSERTERS": [
{
"ref": "MY-ASSERTER-NAME",
"src": "./MyCustomAsserter.js",
"global": false,
"args": {
"my-arg-1": "something"
}
}
]
}
}
}
my-test-case
#me
hi
#bot
hi
MY-ASSERTER-NAME some-arg1|some-arg2