【发布时间】:2019-09-24 22:12:09
【问题描述】:
我正在为我的 Hubot(充当 Slack 机器人)编写一个简单的测试,以检查我的机器人是否发送回复以响应触发器。我已经按照docs 中显示的示例进行操作,但测试结果为AssertionError(详情如下),我不知道为什么。任何建议将不胜感激。
我认为问题与测试有关,而不是脚本 (break-start.coffee),因为当我通过从 Slack 向机器人发送实际消息来测试脚本时,我得到了正确的答复。
# break-start.coffee
# Basically, the bot says "Later alligator" to any user going on lunch break.
module.exports = (robot) ->
robot.respond /off to lunch/i, (res) ->
res.reply('Later alligator')
# break-start-test.coffee
'use strict'
Helper = require('hubot-test-helper')
helper = new Helper('../scripts/break-start.coffee')
request = require('request')
expect = require('chai').expect
describe 'bot responds to user message', ->
beforeEach ->
# Set up the room before running the test.
@room = helper.createRoom()
afterEach ->
# Tear it down after the test to free up the listener.
@room.destroy()
it 'responds to users who are off to lunch', ->
@room.user.say('bob', '@hubot Off to lunch').then =>
expect(@room.messages).to.eql [
['bob', '@hubot Off to lunch']
['hubot', '@bob Later alligator']
]
# The error message
AssertionError: expected [ [ 'bob', '@hubot Off to lunch' ] ] to deeply equal [ Array(2) ]
+ expected - actual
[
"bob"
"@hubot Off to lunch"
]
+ [
+ "hubot"
+ "@bob Later alligator"
+ ]
]
顺便说一句,之前在这里发布过一个非常相似的question,但没有得到答复。
【问题讨论】:
标签: debugging testing coffeescript hubot