jefflau / jest-fetch-mock

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

Promise suggestion #54

Closed AllenFang closed 6 years ago

AllenFang commented 6 years ago

Hey @jefflau

Preface

About Promise.finally is already going to stage 4, some promise library already support finally function.

Issue

Recently, I used finally with fetch in my code, everything is work well, but when I writing the test leverage by jest-fetch-mock, there's something wrong. Anyway, the modern browser's fetch already support finally except for Edge. you can try it easily on browser dev tool

Root cause

I think due to jest-fetch-mock still use native Promise so that some people will got above issue.

Do you consider to use promise-polyfill to fix this issue?, it's already support finally

Probably, I can try to fix this issue by a PR after your confirmation

jefflau commented 6 years ago

I'm open to this. Could you show me how you would implement it?

AllenFang commented 6 years ago

hey jeff, I think it's not very difficult probably. We can just try to replace the Promise by promise-polyfill

jefflau commented 6 years ago

Sounds good!