hubot-test-helper | Helper for testing hubot script | Chat library
kandi X-RAY | hubot-test-helper Summary
kandi X-RAY | hubot-test-helper Summary
Helper for testing Hubot script.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of hubot-test-helper
hubot-test-helper Key Features
hubot-test-helper Examples and Code Snippets
Community Discussions
Trending Discussions on hubot-test-helper
QUESTION
I'm writing a test for my Hubot (which acts as a Slack bot). Triggered by certain Slack messages, the bot sends an HTTP POST request to a separate Rails app. How can I check in my test script that the HTTP request has been sent? My guess was that I should check the contents of the robot.logger
(please let me know if there's a better way) - but if so, how can I access the log in the test?
Hubot script (basically, it informs the Rails app about a user who is leaving the office to take a break):
...ANSWER
Answered 2019-May-09 at 07:54I wouldn't advise writing tests depending on logs. The log is a side-effect of the program. If you change the log output, the tests will fail, even though the functionality is still correct.
Instead you should use a library to mock out and check if the http request was performed. Actually making the request would be a side-effect, and again shouldn't be done in your tests (what if you cause excessive load on an external service due to tests running?
You are already using the nock
library to catch the request. It can also be used to check if the request was made (see the expectations docs from the nock repo).
Here is an example using the requestScope.done()
from nock in your test.
QUESTION
I'm writing a simple test for my Hubot (which acts as a Slack bot) to check that my bot sends a reply in response to triggers. I've followed the example shown in the docs, but test results in an AssertionError
(details below) and I'm not sure why. Any advice would be greatly appreciated.
I assume the issue has to do with the test, not the script (break-start.coffee
), since I got the correct reply when I tested the script by sending an actual message to the bot from Slack.
ANSWER
Answered 2019-May-07 at 11:36I think the problem is an indentation error.
The @room.user.say
call is being passed an empty function as a promise resolution rather than the expect block, as this should be indented another level.
That fits with the result that only one message is in the room, as the expect
call got executed before the async @room.user.say()
got executed:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install hubot-test-helper
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page