mtsmfm / hubot-test-helper

Helper for testing hubot script
MIT License
115 stars 40 forks source link

Timeout in beforeEach #52

Open viraptor opened 6 years ago

viraptor commented 6 years ago

I'm trying to run the tests for a number of service. Unfortunately the first test always fails with:

1) ping "before each" hook for "replies pong to user":
  Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

This happens for the first test only - the rest of them pass correctly. The tests are run under docker based on node:4, with hubot-test-helper between 1.5.1 and latest.

Strangely, this works just fine on local machines and then fails on a buildkite agent. Same container, same versions of dependencies.

The test is just a very simple ping:

expect = require('chai').expect

Helper = require('hubot-test-helper')
helper = new Helper('./../scripts/ping.coffee')

describe 'ping', ->
  room = null

  beforeEach ->
    # Set up the room before running the test
    room = helper.createRoom()

  afterEach ->
    # Tear it down after the test to free up the listener.
    room.destroy()

  context 'user says ping to hubot', ->
    beforeEach ->
      room.user.say 'alice', 'hubot PING'
      room.user.say 'bob',   'hubot PING'

    it 'replies pong to user', ->
      expect(room.messages).to.eql [
        ['alice', 'hubot PING']
        ['bob',   'hubot PING']
        ['hubot', 'PONG']
        ['hubot', 'PONG']
      ]

Any ideas where to look for solutions / what to try are welcome.

viraptor commented 6 years ago

The issue is resolved by creating each helper only for each specific script, not for the script directory. I don't understand why though...