Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HTTP mocking #26

Open
4 tasks
kunal-kushwaha opened this issue Jul 6, 2020 · 1 comment
Open
4 tasks

Support for HTTP mocking #26

kunal-kushwaha opened this issue Jul 6, 2020 · 1 comment
Assignees
Labels
help wanted Extra attention is needed
Projects

Comments

@kunal-kushwaha
Copy link
Member

Summary

When creating applications and libraries that communicate over the network, you usually want to stub out or otherwise replace the network calls with some canned responses. While module mocking works, it often couples your test code to the particular network abstraction you’ve chosen. And setting up a full test server for every test is often slow, especially if you want to set it up fresh for every single test. To address this problem, Jest should support mocking out at the low level network layer via a dedicated API. Doing so would allow deep integration into reporters and watch plugins, allowing the user to for example record some real requests, and have Jest store them on disk for later use.

Deliverables

  • Implement low-level stubbing of http
  • Implement high-level API for setting up canned responses
  • Implement some way of recording real requests/responses and storing them to disk

TODO

  • Research what APIs/module exist for this problem space today

Test Plan

TBD

References

jestjs#6081

@kunal-kushwaha kunal-kushwaha added the help wanted Extra attention is needed label Jul 6, 2020
@kunal-kushwaha kunal-kushwaha added this to To do in MLH x Jest Jul 6, 2020
@SimenB
Copy link
Collaborator

SimenB commented Jul 21, 2020

Known alternatives:

https://kentcdodds.com/blog/stop-mocking-fetch is also interesting reading when tackling this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
MLH x Jest
  
To do
Development

No branches or pull requests

3 participants