node-slack-sdk icon indicating copy to clipboard operation
node-slack-sdk copied to clipboard

Make the `axios` instance public in the `WebClient`

Open mwildehahn opened this issue 6 years ago • 2 comments

Description

This is useful when writing tests when you want to use https://github.com/axios/moxios to stub out requests.

What type of issue is this? (place an x in one of the [ ])

  • [ ] bug
  • [x] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Packages:

Select all that apply:

  • [x] @slack/web-api
  • [ ] @slack/events-api
  • [ ] @slack/interactive-messages
  • [ ] @slack/rtm-api
  • [ ] @slack/webhooks
  • [ ] I don't know

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

mwildehahn avatar May 24 '19 20:05 mwildehahn

It's not guaranteed this module will always be dependent on axios--in fact, a few versions ago, it wasn't! It used to depend on got. My point is testing with the assumption that this package depends on axios may break your tests if we change to a different HTTP library 😕. This is why the implementation isn't exposed.

But your concern for mocking requests is very valid! A useful tool for mocking Slack Platform requests is steno.

Steno is a tool for recording and replaying HTTP requests and responses, to and from the Slack Platform, in order to generate testing fixtues for a Slack App.

clavin avatar May 27 '19 16:05 clavin

I don't think we should expose axios either. in fact i don't think you should be using axios, got or node's http module directly i think you should use any fetch library that can be conditionally imported only when needed to make it less dependent on anything else...

it's impossible to use axios in service workers as it only works with xhr

jimmywarting avatar Jul 06 '22 22:07 jimmywarting

Agreed with @jimmywarting !

I will close this issue, but if folks have strong opinions feel free to chime in.

filmaj avatar Jan 26 '24 21:01 filmaj