IanVS / vitest-fetch-mock

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

Update to vitest 2 #17

Closed birtles closed 2 months ago

birtles commented 2 months ago

Updating to vitest 2 causes TypeScript errors for me since it seems like the typings for Mock have changed.

Specifically I think the following code:

https://github.com/IanVS/vitest-fetch-mock/blob/7450d033c809929462d2af50fa294cf4731150fd/types/index.d.ts#L20-L21

Needs to change to:

export interface FetchMock
  extends Mock<(resource: string | Request | undefined, options: RequestInit | undefined) => Promise<Response>> {

Just changing that appears to fix it for me.

I'm happy to make up a PR if that seems right.

IanVS commented 2 months ago

Thanks for the catch. Yep, that seems correct to me, if you'd like to submit a PR I'll merge it and cut a new 2.0 beta version, since I think this is a breaking change.

birtles commented 2 months ago

Thanks for the catch. Yep, that seems correct to me, if you'd like to submit a PR I'll merge it and cut a new 2.0 beta version, since I think this is a breaking change.

Great, thank you. I've made up PR #18 for this.