Cannot access component variables (via Vue Test Utils wrapper, when using Vuetify) #24753
Replies: 4 comments 4 replies
-
Hi @devjared1, there are a couple of things to think about here. Since you are still on Cypress 9 and the alpha version of CT, this article I wrote might be helpful: https://css-tricks.com/testing-vue-components-with-cypress/#aa-adding-attributes-required-by-vuetify - it avoids the It's based on this reference repo: https://github.com/elevatebart/cy-ct-vuetify. This doesn't set plugins in the mount command, and it's possibly too simple an example compared to what you are doing. There are some other directions around working with Vuetify here: https://docs.cypress.io/guides/component-testing/vue/examples#Replicating-the-expected-Component-Hierarchy - that uses a slightly different way of setting up the plugin. There have been several small but potentially important changes in Cypress Component Testing between the alpha you are using, the beta that came with v10, and the now full release in v11. So I would be curious if it's possible to upgrade your project and see what the experience is in the latest. |
Beta Was this translation helpful? Give feedback.
-
Converted this issue to a discussion, since it doesn't seem to be an issue with Cypress itself (and deals with an old version), but let's keep talking to get this working. |
Beta Was this translation helpful? Give feedback.
-
@marktnoonan I updated my repo to the latest Cypress (11.2.0) but I am still seeing the same issue. I actually have it working in one test repo located here. However, I have not been able to replicate it in my repo. I even scaffolded a new Vite/Vue3 project (no Vuetify), added the latest Cypress, and that repo is not working correctly either. It is located here. |
Beta Was this translation helpful? Give feedback.
-
@marktnoonan I still face this issue, my versions:
Without wrapping into a
|
Beta Was this translation helpful? Give feedback.
-
Current behavior
Using Cypress 9.7.0, after adding the Vuetify plugin to our Vue3/Vite app, I am not able to access component variables or methods in a component test.
Desired behavior
Before adding the Vuetify plugin, I was able to access component variables and methods.
Test code to reproduce
Here is my
cypress\index.js
file:TestNavbar.vue file:
TestNavbar.cy.js file
Before we added the Vuetify plugin, I was able to access component variables after mounting with
Cypress.vueWrapper.vm.variableName
. Now, since we have to wrap components with theVApp
component in tests,Cypress.vueWrapper.vm
is tied to theVApp
component. I thought that doingCypress.vueWrapper.getComponent(TestNavbar).vm.variableName
would give me access but it isundefined
.Does anyone have any suggestions on anything else to try? Thanks in advance!
Cypress Version
9.7.0
Node version
16.18.0
Operating System
Windows10
Debug Logs
No response
Other
No response
Beta Was this translation helpful? Give feedback.
All reactions