jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
886 stars 117 forks source link

Mock Request.redirect() #191

Open markjaquith opened 3 years ago

markjaquith commented 3 years ago

Request.redirect() isn't currently mocked.

https://developer.mozilla.org/en-US/docs/Web/API/Response/redirect

I'm currently using this:

Response.redirect = (url: string, status: number = 302) =>
    new Response(null, {
        headers: {
            Location: url,
        },
        status,
    }
);
yinzara commented 3 years ago

Agreed, I think it's worth adding this if you wanted to submit a PR