我需要访问我vuex店柏树测试,所以我增加了应用程序在我main.js window对象:
const app = new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");
window.vueApp = app;
然后我尝试访问它在我的登录命令(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");
});
但它总是不确定的,什么是我做错了什么?