Not able to mock fetch API properly in unit tests with jest, specifically .formData() #8325
Replies: 1 comment
-
Nevermind, I realized I wasn't passing the data to my Request.... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to figure out how to write unit test for actions. I have an action that use
.formData()
off of theRequest
object. This API is not available in the node js fetch implementation used by jest. What is the recommended approach to mock this or use the web api instead? I've tried importing whatwg-fetch in a jest setup file to no avail.The unit test:
Error:
I really wish there a little bit more docs on unit testing and not only on component testing. What are most people doing for unit tests in Remix apps? I see many conversations around E2E testing and almost nothing around unit testing. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions