You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have recently added the Vuetify plugin to our Vue3/Vite app. I have went through the documentation and added the necessary steps to wrap the components in the parent VApp component. Here is my cypress\index.js file:
import { VApp } from 'vuetify/lib/components/VApp/index.mjs';
import { h } from 'vue';
import { mount } from '@cypress/vue';
Cypress.Commands.add("mount", (component, props, args) => {
return mount(
{ render: () => h(VApp, {}, [h(component, props)]) },
{ ...args }
);
});
import TestNavbar from './TestNavbar.vue';
import vuetify from '../plugins/vuetify';
describe('Navbar component tests', () => {
it.only('Default view', () => {
cy.mount(TestNavbar, {}, {
global: {
plugins: [vuetify]
}
})
.then(() => {
cy.get('[data-cy="navbar"]').should('be.visible');
cy.get('[data-cy="drawer-btn"]').should('be.visible');
cy.get('[data-cy="title"]').should('be.visible').then((span) => {
expect(span.text()).to.eq('Test Title');
});
// before Vuetify plugin
console.log(Cypress.vueWrapper.vm.testFoo);
// after Vuetify plugin, get the nested TestNavbar component
console.log(Cypress.vueWrapper.getComponent(TestNavbar).vm.testFoo);
});
});
});
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 the VApp component in tests, Cypress.vueWrapper.vm is tied to the VApp component. I thought that doing Cypress.vueWrapper.getComponent(TestNavbar).vm.variableName would give me access but it is undefined.
Does anyone have any suggestions on anything else to try? Thanks in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We have recently added the Vuetify plugin to our Vue3/Vite app. I have went through the documentation and added the necessary steps to wrap the components in the parent
VApp
component. Here is mycypress\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!
Beta Was this translation helpful? Give feedback.
All reactions