johannschopplich/nitro-test-utils

Please don't change `$fetch` return type

Closed this issue · 1 comments

pi0 commented

Hi. Thanks for making this amazing util ❤️ Coming from nitrojs/community#5, I had a more thorough look at the docs.

Something I discovered from docs is that $fetch (from test-utils) is returning an object contrary to what $fetch does in Nitro, Nuxt (client and server) and ofetch itself that returns the response body.

I understand the reasoning behind having this interface but using the same name is a huge fragmentation that the same util behaves differently in test utils. Imagine if someone new to the codebase looks at $fetch and notices it is different in tests only. (see ofetch philosophy also. ofetch itself does not shadow fetch)

I would highly recommend using a distinct name such as $fetch.full, or $testFetch, or anything that is not the same name or alternatively advocates a normal fetch interface. I have uses standard Response format in h3 v2 tests and little verbosity didn't really bother with all tests.

Thanks a lot for the feedback! Completely understandable. I have changed the name of the function to $fetchRaw as such to indicate what it really does.