loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.93k stars 1.06k forks source link

Replace `@hapi/shot` with `light-my-request` #6391

Open bajtos opened 4 years ago

bajtos commented 4 years ago

Rework @loopback/testlab to use light-my-request for stubbing HTTP requests & responses.

Arguments for the change:

rahil1304 commented 3 years ago

Hey, I'd like to work on this issue. Could you provide some more information?

bajtos commented 3 years ago

Hi @rahil1304, thanks for offering your help! What kind of information are you looking for?

As for this issue in particular:

bajtos commented 3 years ago

Unfortunately, we don't have tests for shot inside testlab, I think we rely on tests in other packages in the monorepo to verify the functionality. You can run npm test in the monorepo root directory to verify that everything keeps working.

Last but not least, the commit message should annotate the change as breaking, see Making breaking changes in our developer docs.

bajtos commented 3 years ago

Also feel free to ask for help in #loopback-contributors channel, you can join our Slack workspace here.

rahil1304 commented 3 years ago

Hey @bajtos I needed some help with the code in the shot.ts file.

import {
  Listener as ShotListener,
  RequestOptions as ShotRequestOptions,
  ResponseObject,
} from 'shot'; 

So these are the particular libraries that are being used from @hapi/shot. Just confirming, I need to find the similar libraries that are being used in light-my-way, and accordingly replace it, right? The rest of the code in shot.ts stays the same, right?

bajtos commented 3 years ago

Hey @bajtos I needed some help with the code in the shot.ts file.

import {
  Listener as ShotListener,
  RequestOptions as ShotRequestOptions,
  ResponseObject,
} from 'shot'; 

So these are the particular libraries that are being used from @hapi/shot. Just confirming, I need to find the similar libraries that are being used in light-my-way, and accordingly replace it, right? The rest of the code in shot.ts stays the same, right?

Yes, that's correct.

I just realized that the issue title and description were referring to an incorrect module light-my-way, which does not exist. The correct module name is light-my-request, see https://www.npmjs.com/package/light-my-request.

Sorry for the confusion I created 🙈

AFAICT, light-my-request provides InjectionOptions instead of RequestOptions (see light-my-request/index.d.ts#L31), Response instead of ResponseObject (see light-my-request/index.d.ts#L73. I am not sure what name they use instead of Listener, perhaps DispatchFunc?

blackpandan commented 3 years ago

hello, I would love to work on this

hacksparrow commented 3 years ago

@blackpandan sure, please go ahead.

ConaGo commented 3 years ago

Hi there, if this Issue is still not resolved i would like to give it a shot!

achrinza commented 3 years ago

Sure thing, @ConaGo! Feel free to ask queries here or on #loopback-contributors on Slack. The maintainers will try to help where possible.