nuxt-open-fetch icon indicating copy to clipboard operation
nuxt-open-fetch copied to clipboard

Add test utilities to mock `useLazy*` and `use*`

Open huang-julien opened this issue 1 year ago • 1 comments

Describe the feature

Hey :wave:

First, good job with the module. Love using it so far. I encountered a small issues while testing. Mocking open fetch composable is kinda hard due to typescript not being able to infer the return type of the composable.

ex:

// @ts-expect-error need this as TS is not able to infer
vi.mocked(useOpenFetch).mockImplementation((url) => {
  if (url === '/some-api') {
   return Promise.resolve({ data: ref({}), error: ref({}), /**.....**/ })
 }
  throw new Error('')
})

would be nice to provide some utilities to help users to mock those composables

Additional information

  • [ ] Would you be willing to help implement this feature?

Final checks

huang-julien avatar Aug 19 '24 15:08 huang-julien

https://openapi-ts.dev/examples

Norbiros avatar Aug 09 '25 10:08 Norbiros