在Botium绑定完成后运行其他声明代码

问题描述 投票:0回答:1

在完成Botium绑定后如何运行其他断言?

const bb = new BotiumBindings({ convodirs: ['/spec'] })
BotiumBindings.helper.mocha().setupMochaTestSuite({ bb })

// TODO: GET request to an external API.
javascript node.js mocha
1个回答
0
投票

向Botium添加自定义断言逻辑的推荐方法是向Botium添加自己的断言模块。您可以找到详细信息here,但总之:

  1. 创建文件MyCustomAsserter.js
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()
  }
}
  1. botium.json中注册
{
  "botium": {
    "Capabilities": {
      ...
      "ASSERTERS": [
        {
          "ref": "MY-ASSERTER-NAME",
          "src": "./MyCustomAsserter.js",
          "global": false,
          "args": {
            "my-arg-1": "something"
          }
        }
      ]
    }
  }
}

  1. 在convo文件中使用此断言器:
my-test-case

#me
hi

#bot
hi
MY-ASSERTER-NAME some-arg1|some-arg2

© www.soinside.com 2019 - 2024. All rights reserved.