Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating from 1.7.0 to 1.8.1/1.9.0 breaks #60

Open
bteng22 opened this issue Feb 19, 2019 · 1 comment
Open

Updating from 1.7.0 to 1.8.1/1.9.0 breaks #60

bteng22 opened this issue Feb 19, 2019 · 1 comment

Comments

@bteng22
Copy link

bteng22 commented Feb 19, 2019

Since updating hubot-test-helper from 1.7.0 to 1.8.1 or 1.9.0, my project has been experiencing an odd issue with the sinon stubs we're creating for our hubot scripts. Essentially, we're creating an instance of aws's elasticbeanstalk and verifying a method was called a certain number of times

For example

beforeEach(() => {
      describeEnvironmentsStub = sinon.stub(Object.getPrototypeOf(new aws.ElasticBeanstalk()),
        'describeEnvironments').returns('some environment');
    });

    it('asks for environment information from various elastic beanstalks', async () => {
      await room.user.say('someUser', '@hubot list versions');
      expect(describeEnvironmentsStub.callCount).to.equal(1);
    });

Where the elasticbeanstalk instance is created in the script file outside the module.exports

let devElasticbeanstalk = new aws.ElasticBeanstalk();

module.exports = (robot) => {
  robot.respond(/list versions/, msg => {
    ...where we eventually call devElasticbeanstalk.describeEnvironments.
  });
}

In 1.8.1+, the stub fails to be created and the describeEnvironments function is undefined on the devElasticbeanstalk instance. This isn't the case in 1.7.0.

Any clue into what could be breaking it would be super helpful. Thanks!

@bteng22
Copy link
Author

bteng22 commented Feb 19, 2019

After further investigation, it seems upgrading to 1.8.1 or above executes hubot's respond listener after the test cases have been run, so my stubs will never capture the callCount in the script files. Downgrading to 1.7.0 reverses this order and calls my implementation code before my test cases.

I'm looking through the 1.8.1 commits and it's hard to pinpoint where exactly this implementation changed since the Helper class was simply converted from coffee to regular javascript.

I tried following the examples on the README using the co package and I'm getting the same results :\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant