-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use vitest spy within nuxt 3 component methods. #763
Labels
Comments
Bumping this as it seems to have been complete forgotten but is still and issue. Just like the OP I have found no working way to actually ,spy on user defined component methods... |
It definitely require additional developments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
This is one of the environments i came across the problem:
[11:15:23 AM] Working directory: /Users/lorenzorottigni/Documents/gitlab_private/portfolio.rottigni.tech
[11:15:23 AM] Nuxt project info: (copied to clipboard)
[11:15:23 AM] 👉 Report an issue: https:/nuxt/nuxt/issues/new
👉 Suggest an improvement: https:/nuxt/nuxt/discussions/new
👉 Read documentation: https://nuxt.com
Reproduction
The crucial file is MyComponent.spec.ts:
https://stackblitz.com/~/github.com/LorenzoRottigni/nuxt-test-utils-vitest-spy
Describe the bug
I'm currently facing challenges in testing a component method within a Nuxt environment. Specifically, I'm attempting to spy on a component method to test its interactions within template events. Despite researching similar cases online, I've yet to find a clear solution to this issue.
One suggestion I encountered was to define the spy before the component mounts. However, I'm unable to access
wrapper.vm
before mount time, complicating this approach. Additionally, I experimented with spying on the global injected$fetch
method from the 'ofetch' library. Unfortunately, this led to another error regarding the inability to redefine the variable$fetch
when attempting variations like:It appears that this issue may not be directly tied to the nuxt-test-utils package. Nevertheless, I wanted to bring it to your attention in the hopes that someone might offer guidance or assistance. I'm eager to find a resolution and would appreciate any insights or suggestions you might have.
I'm also considering reporting a similar issue to the vue-test-utils package, as I suspect that this problem might be reproducible outside of the Nuxt environment.
Thank you for your time and assistance.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: