Fix Jest memory leak from nock.restore()
Jest appears to be losing reference to the patched http and https libs when required inside a loop.
Resolves https://github.com/nock/nock/issues/2383
@gr2m is there a way we can get this in? this is the only barrier to my adoption of nock and this PR seems to be alright
@gr2m is there a way we can get this in? this is the only barrier to my adoption of nock and this PR seems to be alright
Thank you for testing and confirming that it works for you!
We need a test that prevents us from future regression. Could you help out with that?
@gr2m Any chance this gets added any time soon? I understand the ask for a test to prevent future regression, but short of adding a jest dependency and running a test with --detectLeaks, that seems like a non-trivial ask. The change on the other hand, seems pretty straightforward. It definitely seems better to not require both modules twice, imho.
I'd love to add nock to my current project at work, but I'm finding it very difficult to work around this issue (which in the worst case, seems to be inefficient usage of require), and removing --detectLeaks is not an option for me.