I need to access my vuex store in cypress tests, so i added the app to the window object in my main.js:
const app = new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");
window.vueApp = app;
And then i try to access it in my login command (commands.js):
cy
.request({
method: "POST",
url: "http://localhost:8081/api/v1/login",
body: {},
headers: {
Authorization: "Basic " + btoa("administrator:12345678")
}
})
.then(resp => {
console.log("app:", window.vueApp);
...
window.localStorage.setItem("aq-username", "administrator");
});
but it's always undefined, what am i doing wrong?