Has anyone been testing pinia in vue3? In vue2 I'd...
# help
p
Has anyone been testing pinia in vue3? In vue2 I'd used this sweet trick of exposing the entire vue instance on the window object during testing in order to grab the centralized store off it with
cy.window().its('app.$store')
like it shows in this article: https://www.cypress.io/blog/2017/11/28/testing-vue-web-application-with-vuex-data-store-and-rest-backend/ But in vue3 with composition api, there is no centralized store, just many individual stores that can (or not) be consumed by each component via an import of a
useSomeStore()
function. This function doesn't appear to be consumable directly in cypress tests, so I'm wondering how to access my pinia stores in cypress
I'm going to poke around the app instance to see if I'm missing a reference to the stores
g
do you have an example repo with small app to use as a demo for a test?
p
No, but I can create one, thanks for asking
I have three tests in the test file: 1 that reads the DOM (this works as expected of course) And two different attempts to access a store value directly in cypress: via the helper function that components consume (fails b/c no global pinia instance) and via the root component instance in the say I do in vue2
5 Views