jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
882 stars 116 forks source link

fixes #152 type definitions for UrlOrPredicate #154

Closed yinzara closed 4 years ago

yinzara commented 4 years ago

This PR fixes Issue #152 however it technically changes the behavior of the library if you were not using the TypeScript definition as it now follows the TypeScript definitions correctly.

Anyone who used the recent "condition mocking" functionality may need to make a change to their code.

If they passed a conditional URL string without a path (i.e. http://foo.com) they must append a trailing slash or it will never match (as the ".url" property of a request always has a path). For regexs, they will match against the URL with the trailing slash.

If they passed a predicate function, that function is now passed a fetch "Request" object instead of the url string (as was previously defined in the TypeScript definitions).

jefflau commented 4 years ago

Will merge this in and create a release explaining this just in case