Skip to content
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

Bug: Cannot acess global plugin in test file (wrapper.vm.$plugin) #2298

Closed
ElVisPL opened this issue Jan 10, 2024 · 4 comments
Closed

Bug: Cannot acess global plugin in test file (wrapper.vm.$plugin) #2298

ElVisPL opened this issue Jan 10, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@ElVisPL
Copy link

ElVisPL commented Jan 10, 2024

Describe the bug

I'm migrating vue2 to vue3 (test utils too)
In vue2 if I had global plugin that was installed with createLocalVue then it was accessible under wrapper.vm (e.g wrapper.vm.$logger), in vue3 if i pass plugin to global.plugins then it is passed correctly to tested component, but in the test itself I don't have access to it so e.g I can't mock it

It works though for external provider plugins like vuetify (wrapper.vm.$vuetify is there)

To Reproduce

https://stackblitz.com/edit/github-guxdre-g64fcl?file=src%2Fcomponents%2F__tests__%2FHelloWorld.spec.ts

In test file see console.log

Expected behavior

Global plugin is accessible e.g wrapper.vm.$logger

@ElVisPL ElVisPL added the bug Something isn't working label Jan 10, 2024
@cexbrayat
Copy link
Member

Hi @ElVisPL
Thanks for the repro.

Interesting, because we have a similar test case in this repo https://github.com/vuejs/test-utils/blob/main/tests/config.spec.ts
So I would have expected this to work as well.

Do you think you could look into it and open a PR? We would gladly review it and merge it. The test file I mentioned is a good place to try to add your repro and see if you still reproduce the issue.

@taku-y-9308
Copy link
Contributor

@cexbrayat
Has this issue been fixed by my pr?
#2386

@cexbrayat
Copy link
Member

@taku-y-9308 Maybe it does, I'm not sure. We'll check when the new version is released 👍

@cexbrayat
Copy link
Member

I think @taku-y-9308 did fix the issue: if I update to v2.4.6 in @ElVisPL 's stacklitz repro, the $logger is defined.

Let's close the issue, and thanks @taku-y-9308 for solving this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants