nuxt-open-fetch
nuxt-open-fetch copied to clipboard
Add test utilities to mock `useLazy*` and `use*`
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
- [X] Read the contribution guide.
- [X] Check existing discussions and issues.
https://openapi-ts.dev/examples