fetch-mock icon indicating copy to clipboard operation
fetch-mock copied to clipboard

Support exact-matching on FormData bodies

Open kylekthompson opened this issue 4 years ago • 0 comments

Hello 👋

While attempting to mock some client-side calls to fetch using fetch-mock 9.11.0, I was hoping I'd be able to match FormData 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 to FormData only if you'd like (I'll just need to investigate a little more to make it compatible with both client and server environments).

kylekthompson avatar Nov 08 '21 17:11 kylekthompson