Closed ghost closed 3 years ago
Wow I was close. Fixed it with brackets around store:
const extensions = {
plugins: [Vuex],
mixin: [{ store }]
}
Then I had trouble actually getting and setting the store values but I was able to in a .then() method off the mount:
mount(ArrayWidget, {
extensions,
propsData: {
parameters: ['TGT', 'PKT', 'ITEM', null, null, null, null, 'RAW']
}
}).then(() => {
expect(Cypress.vue.$store.state.tlmViewerItems[0]).to.eql({
target: 'TGT',
packet: 'PKT',
item: 'ITEM',
type: 'RAW'
})
Cypress.vue.$store.commit('tlmViewerUpdateValues', [['hello'], []])
})
I'm trying to test a Vue component which uses Vuex. The standard way to use Vuex is to inject it globally in main.js:
But then when I try to test an individual component the injected this.$store does not exist. I think I need to inject it somehow but I can't get the syntax correct. I see in your example I need to include Vuex in the plugins but how do I create the this.$store in the component?