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

Example usage with @slack/client #31

Open
timkinnane opened this issue Oct 25, 2018 · 0 comments
Open

Example usage with @slack/client #31

timkinnane opened this issue Oct 25, 2018 · 0 comments

Comments

@timkinnane
Copy link

timkinnane commented Oct 25, 2018

Hi, this looks like a great utility, but I'm having trouble getting it working with the Slack SDK, as opposed to the more bespoke solutions in the examples. Below is my attempt, but I'm getting this error: @slack/client:RTMClient2 unable to RTM start: Cannot read property 'id' of undefined

const { expect } = require('chai')
const { RTMClient } = require('@slack/client')
const slackMock = require('slack-mock')()
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
const token = process.env.BOT_SLACK_USER_TOKEN

describe('[client]', () => {
  before(() => {
    slackMock.web.addResponse({
      url: 'https://slack.com/api/rtm.start',
      status: 200,
      body: {
        ok: true,
        self: { name: 'mockSelf', id: 'mself' },
        team: { name: 'mockTeam', id: 'mteam' }
      }
    })
    return delay(50)
  })
  beforeEach(() => {
    slackMock.reset()
  })
  after(() => {
    return slackMock.rtm.stopServer(token)
  })
  describe('connect', () => {
    it('is able to connect', async () => {
      const rtm = new RTMClient(token)
      const connection = await rtm.start({})
      expect(connection.ok).to.equal(true)
      expect(connection).to.include.keys(['team'])
    })
  })
})

p.s. The test works if I remove slack-mock.

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