Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

test: allow for easier mocking of requests #837

Merged
merged 1 commit into from
Aug 21, 2018
Merged

Conversation

jacobheun
Copy link
Contributor

The way http.request is currently being included makes it a huge pain to mock the api requests with something like nock, since the request function cannot be stubbed the way it's being included.

This PR changes the way .request is being included, to allow for easier mocking.

I am using this change locally with nock to test some upcoming module additions to libp2p.

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>
@ghost ghost assigned jacobheun Aug 16, 2018
@ghost ghost added the in progress label Aug 16, 2018
@jacobheun jacobheun requested a review from alanshaw August 16, 2018 19:48
@jacobheun
Copy link
Contributor Author

For reference, testing in libp2p, here is a failed build of me using nock without this change https://ci.ipfs.team/blue/organizations/jenkins/libp2p%2Fjs-libp2p/detail/feat%2Fpeer-content-routing/3/pipeline

And an all green build of this branch using package.json resolutions for yarn: https://ci.ipfs.team/blue/organizations/jenkins/libp2p%2Fjs-libp2p/detail/feat%2Fpeer-content-routing/4/pipeline

@alanshaw alanshaw merged commit 2cafe9b into master Aug 21, 2018
@alanshaw alanshaw deleted the test/easier-mocking branch August 21, 2018 15:17
@ghost ghost removed the in progress label Aug 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants