[vitest] how to make sure inner dependency method was called in service #9161
Unanswered
lkurylo
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a Vue 3 project created with Vite and Vitest for unit testing. My problems are related to creating properly mocks/spies.
I have a composable function which have an inner dependency
I created a bunch of unit tests:
My problem is related to last test. In this specific case I can spy on the global console object and it seems to work properly. But in my real code, I have no global object to relay on, so I need to have the possibility to check, if that mock function was even called. The way I did it in the last test doesn't work. How can I fix it? Or maybe should I use a spy too? But don't know how to write it to make it work.
A working project is available here: https://stackblitz.com/edit/vitest-dev-vitest-toomcq?file=test%2FuseMainService.test.ts
Beta Was this translation helpful? Give feedback.
All reactions