Pretend is a powerful test suite for Hubot, providing mock messaging and internal processes, with helpers to make shorthand assertions using mocha, chai and sinon.
npm install hubot-pretend --save-dev
yarn add hubot-pretend --dev
See the docs for specific usage examples
We have the following Hubot script (hello-world.coffee)...
=robotrespond /hello$/i msgreply 'hello'
Test file processes some messages...
const pretend =const expect =
.readreads in scripts (can be done before test)
.startcreates a robot and adapter to route messages
.usercreates user with helpers for pre-populated message envelopes
.sendpasses messages to
robot.receiveand returns a promise*
.messageskeeps a record of all messages sent and received by the robot
.shutdownresets collections and runs shutdown on the robot
This example shows a minimal dependency approach using the tests's
function on the promise
Other examples in the docs show how to improve the style of such tests using generators with co.
Currently has trouble installing in node v8, I think because of incompatibility with dependencies for node v4. Needs more testing and possibly prune some less important deps. For now node v8 is being removed from Travis supported versions.
Script paths are resolved from the package root, not relative to tests.
Currently, Pretend uses a custom fork of hubot that adds promises to middleware, to allow async tests. It can test your hubot scripts, but it won't use your own package's hubot version. Hopefully in later versions of hubot, async will be supported and Pretend can be adapted to test with the exact dependencies of your hubot projects.
This is a fairly new project, so there's no contrib guidelines yet. Just follow the standard process.
See the TODO list below for the roadmap of objectives if you'd like to help. Or just create an issue and start working on it if you've found something wrong.
Use the NPM scripts to test and build any changes:
npm run test- lint and test current build
npm run dev- lint, compile and test development changes
npm run dev:watch- run dev scripts automatically on change
npm run build- lint, compile, test, regenerate docs
NB: Before publishing, build from Node v4 to ensure babel compatibility
NB: Full test includes usage with compiled JS from build (not tested in dev)
Follow standardsj syntax to avoid bikeshedding.
Use the commitizen cli for writing commit messages.
- fix dependency incompatibility between node 4 and 8
- generate coverage and write missing module tests
- clean up jsDoc format for default export modules
- convert co usage to babel async/await
- convert room/user messages to property getter
- link back to docs for HTH #32, #37, #38
- helper methods to test hubot brain - HTH #31
- helper methods to test user id, other attributes - HTH #26
- helpers and promise returns for get/post request tests
- add end to end test with internal IRC server and adapter