
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
hubot-pretend
Advanced tools
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
or
yarn add hubot-pretend --dev
We have the following Hubot script (hello-world.coffee)...
module.exports = (robot) ->
robot.respond /hello$/i, (msg) -> msg.reply 'hello'
Test file processes some messages...
const pretend = require('hubot-pretend')
const {expect} = require('chai')
describe('Hello World', function () {
it('says hello back', function (done) {
pretend.read('scripts/hello-world.coffee').start()
pretend.user('margaret').send('hubot hello').then(function() {
expect(pretend.messages).to.eql([
['margaret', 'hubot hello'],
['hubot', '@margaret hello']
])
pretend.shutdown()
done()
})
})
})
.read reads in scripts (can be done before test).start creates a robot and adapter to route messages.user creates user with helpers for pre-populated message envelopes.send passes messages to robot.receive and returns a promise*.messages keeps a record of all messages sent and received by the robot.shutdown resets collections and runs shutdown on the robotThis example shows a minimal dependency approach using the tests's done
function on the promise .then.
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 buildnpm run dev - lint, compile and test development changesnpm run dev:watch - run dev scripts automatically on changenpm run build - lint, compile, test, regenerate docsNB: 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.
FAQs
Test Hubot scripts with a mock robot, rooms and users.
We found that hubot-pretend demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.