mbland / slack-emoji-issues

Library for using Slack reaction_added events to file GitHub issues
https://www.npmjs.com/package/slack-github-issues
ISC License
4 stars 3 forks source link

Find permanent fix for integration, smoke test breakage with hubot-test-helper, hubot #15

Open mbland opened 7 years ago

mbland commented 7 years ago

After doing a fresh git clone and npm install (without a package-lock.json file), I picked up hubot-test-helper v1.8.1. As a result, the integration and smoke tests started failing with the following message:

reaction_added listener registration failed: robot.react is not a function

This robot.react method should've been added to Hubot by the hubot-slack adapter (implemented in slackapi/hubot-slack#363, released in hubot-slack v4.2.0). After a bit of digging, I realized this was because:

The problem is that hubot-slack now adds the react method to the CoffeeScript-compatible wrapper function exported by the original hubot/index.js, while the original Robot implementation exported by hubot/es2015.js remains unchanged. Consequently, the MockRobot from hubot-test-helper/src/index.js did not have access to the react function, leading to the test failures.

Upgrading this repository's hubot dependency to ^3.0.01 and adding the following snippet to hubot/slack-github-issues.js resolves the issue for now (coming in a pull request immediately after I file this issue):

require('hubot-slack')
var CoffeeScriptCompatibleHubot = require('hubot')
var Hubot = require('hubot/es2015')
Hubot.Robot.prototype.react = CoffeeScriptCompatibleHubot.Robot.prototype.react

However, this is only a temporary solution. The proposed rewrite from CoffeeScript to ES2015 in slackapi/hubot-slack#429 should ideally rectify the problem and remove the need for the workaround.

1This also required blowing away node_modules and running npm install again, so that hubot-test-helper wasn't still working with its local copy of hubot v3.0.1. Debugging that issue produced another moment of enlightenment.