
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
hubot-mock-adapter
Advanced tools
I've whacked together a couple of Hubot scripts, but then they started getting more complicated. TDD is really the ONLY way to do any kind of meaningful development. But even if you're not TDD'ing, you are testing, right? Right?
I couldn't find an existing method for writing unit tests for Hubot scripts.
After digging around under Hubot's hood, I figured out all I really needed was
an Adapter
implementation I could spy on. That is what you see here.
Let's assume you've got a really simple script, like this:
module.exports = function (robot) {
robot.hear(/Computer!/, function (msg) {
msg.reply("Why hello there! (ticker tape, ticker tape)");
});
};
Create a test file in a folder. e.g. index.test.mjs.
You'll need a Node version > 17.
Assuming your tests are in test/
or have .test.
before the file extension, just run node --test
. For less typing, in your package.json
, add a test
script:
"scripts": {
"test": "node --test"
}
Then you can use npm test
to run your tests!
Create a test file in a folder. e.g. index.js.
You'll need devDependencies
something like this in your package.json
:
"devDependencies": {
"coffeescript": "^2.7.0",
"chai": "^4.3.7",
"hubot-mock-adapter": "^1.x.x",
"mocha": "^10.2.0",
"hubot": "^7.x.x",
}
Assuming your tests are in test/
, just run node_modules/.bin/mocha --exit
. For less typing, in your package.json
, add a test
script:
"scripts": {
"test": "mocha --exit"
}
Then you can use npm test
to run your tests!
FAQs
A mock Adapter for unit testing Hubot scripts
The npm package hubot-mock-adapter receives a total of 79 weekly downloads. As such, hubot-mock-adapter popularity was classified as not popular.
We found that hubot-mock-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.