Support exact-matching on FormData bodies #622
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello 👋
While attempting to mock some client-side calls to
fetch
usingfetch-mock
9.11.0, I was hoping I'd be able to matchFormData
bodies in addition to JSON. I do see in the docs that it's called out that JSON is supported. Would you be open to a change supporting other kinds of bodies?The diff as-is will support exact matches of
FormData
(see the included tests; I've also patched this change locally in my repository as a test and validated that it solves my issues there as well). It also will likely support other exact-matches of bodies (e.g. plaintext), but I've not explicitly called out support for that. I'd be happy to do some work to limit it toFormData
only if you'd like (I'll just need to investigate a little more to make it compatible with both client and server environments).