IanVS / vitest-fetch-mock

Vitest mock for fetch, forked from jest-fetch-mock
MIT License
59 stars 7 forks source link

Add support to mock import of crossFetch #14

Closed leoferreiralima closed 4 months ago

leoferreiralima commented 1 year ago

Added fix to reported issue #13

fix #13

IanVS commented 1 year ago

I'm not sure if this is a good idea, it feels a little unexpected to automatically mock such direct imports from cross-fetch. And I worry that it would break or conflict with the examples of conditional mocking at the end of the README.

In your issue, you showed two different ways to work around the problem of direct imports not being mocked. I wonder if the better solution here is to update the README to clarify the current behavior and present the two approaches you mentioned so that users can set up the mocks themselves if they desire.

What do you think? I'll leave this open for a while and give others a chance to chime in as well, since honestly I don't use this library extensively and maybe I'm missing some context.

All that said, thanks for the issue and the contribution!

leoferreiralima commented 1 year ago

I think is a good option update the read with this context, other alternative is use other method to activate this mock, becaus i think this should be support by the library some way, maybe a method named enableDirectImport() to run this and the users can option to call or not this method as they wish