You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some code which uses fetch, and would like to run automated tests on it. But fetch is a browser technology (c.f JakeChampion/fetch#184 (comment)) and CLI tests are easiest run via node (AFAIK).
How feasible would it be to have another implementation with the same interface, which uses node's http client underneath?
Thanks for all your work so far!
The text was updated successfully, but these errors were encountered:
Hi! I'm not sure why you'd want that, since the comment you link to explains well why doing so would be a bad idea. There'd be subtle semantic differences, so you wouldn't really be able to trust your tests anyway. Additionally, support for node out of the box would at the very least require another layer of indirection, which would significantly increase the amount of code having to be shipped to browsers, adding cost to the primary use case.
But bs-fetch really isn't much more than an interface itself, it doesn't ship with any actual implementation, not even a polyfill, so I think you should be able to just `require('isomorphic-fetch)' to get node support.
Alternatively, as I learned today, there's bs-axios. Though personally I'd just abstract away the low-level IO myself and mock it at a higher level.
I hope this helps, even if it might not be quite what you wanted. I'll go ahead and close this, but feel free to ask any follow-up questions :)
I have some code which uses fetch, and would like to run automated tests on it. But fetch is a browser technology (c.f JakeChampion/fetch#184 (comment)) and CLI tests are easiest run via node (AFAIK).
How feasible would it be to have another implementation with the same interface, which uses node's http client underneath?
Thanks for all your work so far!
The text was updated successfully, but these errors were encountered: