MLH-Fellowship / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
8 stars 3 forks source link

Support for HTTP mocking #26

Open kunal-kushwaha opened 4 years ago

kunal-kushwaha commented 4 years ago

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

TODO

Test Plan

TBD

References

https://github.com/facebook/jest/issues/6081

SimenB commented 4 years ago

Known alternatives:

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