Mocking useSanctumClient #364
-
I'm new to vitest and mocking so maybe I'm doing it wrong but I'm trying to find a way to mock the response from useSanctumClient. Any help would be greatly appreciated. useRegister is a composable that has api calls to our Laravel server - if status is 200 ifSuccessful is set to true. useSanctumClient isn't being mocked and the composable is calling "http://localhost:80/api/summerschool/sessions"
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @rkrater! Behind the scenes, useSanctumClient just creates an instance of Another option is to point sanctum module to your Nuxt app instead of actual API and mock the response instead. You can check an example in the tests used for |
Beta Was this translation helpful? Give feedback.
Hey @rkrater! Behind the scenes, useSanctumClient just creates an instance of
ofetch
client viaofetch.create()
method, so you can check how this object can be mocked.Another option is to point sanctum module to your Nuxt app instead of actual API and mock the response instead. You can check an example in the tests used for
nuxt-auth-sanctum
itself - here.