Hubot单元测试未收到响应 [英] Hubot Unit Testing Not Receiving Response
问题描述
我正在尝试为我的Hubot代码设置一个简单的单元测试,但是我没有收到回复.我将其简化为:
I'm trying to set up a simple unit test for my hubot code and I am not receiving responses back. I have simplified this down to:
test.coffee:
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'
运行测试时,我得到一个断言错误:
When I run my tests, I get an assertion error of:
AssertionError: expected [ [ 'alice', '@hubot PING' ] ] to deeply equal [ Array(2) ]
+ expected - actual
[
"alice"
"@hubot PING"
]
+ [
+ "hubot"
+ "PONG"
+ ]
]
意思是我什么都没有得到回应.我已经尝试将@hubot更改为hubot(这无关紧要).我还验证了它正在查找我的something.coffee,因为当我将该路径更改为错误的路径时,我收到了关于此的错误.
Meaning I am not getting a response back at all. I have tried changing @hubot to hubot (which shouldn't matter). I also verified that it is finding my something.coffee, as when I changed that path to an incorrect one I received an error about that.
我正在遵循> https://hubot.github.com/docs/底部的示例脚本/
感谢您的帮助!
推荐答案
For anyone who reached this thread, I posted a question when I experienced the same issue.
In short, the issue was indentation - the line beginning with expect
was being called before the @room.user.say
was executed. Please see my link for more details.
这篇关于Hubot单元测试未收到响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!