【发布时间】:2018-07-04 23:59:04
【问题描述】:
我正在尝试为我的 hubot 代码设置一个简单的单元测试,但我没有收到回复。我已将其简化为:
test.coffee:
Helper = require('hubot-test-helper')
chai = require 'chai'
expect = chai.expect
helper = new Helper('../hubot-scripts/something.coffee')
describe 'PING', ->
beforeEach ->
@room = helper.createRoom()
afterEach ->
@room.destroy
it 'should PONG', ->
@room.user.say 'alice', '@hubot PING'
expect(@room.messages).to.eql [
['alice', '@hubot PING'],
['hubot', 'PONG']
]
还有一些东西。咖啡:
module.exports = (robot) ->
robot.response /PING$/i, (msg) ->
msg.send 'PONG'
当我运行测试时,我收到以下断言错误:
AssertionError: expected [ [ 'alice', '@hubot PING' ] ] to deeply equal [ Array(2) ]
+ expected - actual
[
"alice"
"@hubot PING"
]
+ [
+ "hubot"
+ "PONG"
+ ]
]
意思是我根本没有得到回复。我尝试将@hubot 更改为hubot(这没关系)。我还验证了它正在找到我的 something.coffee,因为当我将该路径更改为不正确的路径时,我收到了一个错误。
我正在关注https://hubot.github.com/docs/scripting/底部的例子
感谢您的帮助!
【问题讨论】:
标签: coffeescript mocha.js chai hubot