moll / node-mitm

Intercept and mock outgoing Node.js network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Super useful when testing code that hits remote servers.
Other
637 stars 48 forks source link

Added record functionality #40

Closed framp closed 5 years ago

framp commented 7 years ago

This pull request adds support for recording requests, piggybacking on mitm.js support for intercepting net calls.

The data is going to be emitted via a record event.

Originally opened here: https://github.com/moll/node-mitm/pull/38

amarzavery commented 5 years ago

@moll - I would like to record some tests so that I can run them in playback mode in travis-ci. Having the recording functionality would be very useful.

Any reason why this has not been merged?

darlintonprauchner commented 5 years ago

Hi, we talked earlier, this looks to be what I need, could we get this merged?

amarzavery commented 5 years ago

@moll - any updates? Can you please respond?

moll commented 5 years ago

Hey, fellows! Apologies for the two year delay. Time flies when fruit flies, right? :P

Thanks, @framp, for sharing your code! I reckon it could be useful to some! However, this functionality is something I'd rather see either implemented in a library than in Mitm.js itself. Reliable recording seems like a feature with many edge cases and I'm inclined to keep Mitm.js's core fairly light. If you do decide to extract it out, I'd be happy to link to it. @ianwsperber mentions in https://github.com/moll/node-mitm/issues/51 that he'll put something out soon, too.

I'll close the issue here, but the code will fortunately remain here for anyone to take hints from. :)

moll commented 5 years ago

Ah, I see I actually wrote roughly the same response a year ago in https://github.com/moll/node-mitm/pull/38. :D Did you end up releasing something, @framp?

framp commented 5 years ago

I actually did use it in a project, but never got around to properly releasing due to some testing related issues. I can't foresee any time in the near future I could dedicate to this but the code in this branch should be a good starting point for anyone who wants to release something. I'd be happy to give some pointers where needed.

framp commented 5 years ago

The great benefit from a workflow perspective (compared to nock) is how you can just fire up your project specific tests with record, find what you need to stub and fix it in one pass

ianwsperber commented 5 years ago

@moll @framp @amarzavery @darlintonprauchner Hi all! I just made public the aforementioned library I've written on top of YesNo that allows one to record requests. It includes a few other features to simplify HTTP mocking. You can find it here: https://github.com/FormidableLabs/yesno

I'll be continuing development over the next month to work toward a stable 1.0 release late November/early December. Would appreciate any feedback you have to offer. I've tried putting together a complete README, but please reach out if anything is confusing. Hopefully it's at least a good first step 😄Thanks!

darlintonprauchner commented 5 years ago

It looks pretty interesting, I will play with it later down the week and see what I can find!

Thanks!

On Nov 5, 2018, at 11:02 AM, Ian Walker-Sperber notifications@github.com wrote:

@moll https://github.com/moll @framp https://github.com/framp @amarzavery https://github.com/amarzavery @darlintonprauchner https://github.com/darlintonprauchner Hi all! I just made public the aforementioned library I've written on top of YesNo that allows one to record requests. It includes a few other features to simplify HTTP mocking. You can find it here: https://github.com/FormidableLabs/yesno https://github.com/FormidableLabs/yesno I'll be continuing development over the next month to work toward a stable 1.0 release late November/early December. Would appreciate any feedback you have to offer. I've tried putting together a complete README, but please reach out if anything is confusing. Hopefully it's at least a good first step 😄Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/moll/node-mitm/pull/40#issuecomment-435929589, or mute the thread https://github.com/notifications/unsubscribe-auth/AVjFnjHGZci-1kQqta4O-h5xgE6appf7ks5usGEtgaJpZM4K8Xe4.