@slack/web-api dependency causes `invalid_auth` throws on every instantiation of adapter
roeintense opened this issue · comments
Hi folks,
Botkit 4.5.
Noticed while trying to build out integration tests that we kept getting a little blurb like this:
{ Error: An API error occurred: invalid_auth at Object.platformErrorFromResult (.../@slack/web-api/dist/errors.js:50:33) at WebClient.apiCall (.../node_modules/@slack/web-api/dist/WebClient.js:407:28) at process._tickCallback (internal/process/next_tick.js:68:7) code: 'slack_webapi_platform_error', data: { ok: false, error: 'invalid_auth', response_metadata: {} } }
I was able to remove this invalid_auth by stubbing out WebClient.prototype.makeRequest BEFORE the instantiation of the SlackAdapter with fake information. Wondering if the @slack/web-api dependency in botbuilder-adapter-slack has been accomodated for (or there are plans to) in this library?
Hey @roeintense , we got this error as well, we work on this
https://github.com/gratifyguy/botkit-mock/pull/57/files
that is why i suggested
https://github.com/gratifyguy/botkit-mock/pull/57/files#diff-08a4a90fec7ec7a039fb74fba5054ad2R30-R42
I was able to remove this invalid_auth by stubbing out WebClient.prototype.makeRequest BEFORE the instantiation of the SlackAdapter with fake information.
could you share it? probably we could include it in botkit-mock
@ihorrusinko sorry to keep you waiting.
All I do is, right at the top of the beforeEach
where I instantiate my mock stuff, I use @sinonjs/sinon and call:
sinon.stub(WebClient.prototype, "makeRequest").returns({ data: { ok: true, error: {}, response_metadata: {} }, headers: { "x-oauth-scopes": "whateverItDoesNotMatter" } });
Thanks @roeintense we'll look into this.
@ihorrusinko let's cycle about this locally and include it in update-botkit-4.6.2
if it's relevant and not already included.
hey @roeintense
check out new version 4.6.2
here is example how to init slack-adapter so it won't trigger an error again