Javascript 从Cypress访问Vuex Getter的正确方法是什么?
我的Vuex存储中有一个名为Javascript 从Cypress访问Vuex Getter的正确方法是什么?,javascript,vue.js,vuex,cypress,Javascript,Vue.js,Vuex,Cypress,我的Vuex存储中有一个名为viewItems的getter,返回一个数组。 我可以通过以下方式从Cypress测试访问它: Cypress.Commands.add("getStore", () => { return cy.window().its("app.$store"); }); cy.getStore().its("getters.viewItems.length").should("equal&quo
viewItems
的getter,返回一个数组。
我可以通过以下方式从Cypress测试访问它:
Cypress.Commands.add("getStore", () => {
return cy.window().its("app.$store");
});
cy.getStore().its("getters.viewItems.length").should("equal", 13);
它可以工作,但在运行Cypress时控制台上出现错误:
[Vue warn]: Property or method "nodeType" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties
是否有更好的方法访问getter,或者是其他方法?用于从我使用的cypress命令返回内容
谢谢,不过没什么区别。警告仍然在控制台中。我明白了,现在我记得在我们最初的项目中运行vue代码时看到了这样的警告,并且开发团队没有太多注意,直到他们开始破坏代码。这似乎是一个警告,要检查你是否得到了正确的信息。也许你应该联系你的开发团队,向我的开发团队寻求机会,是的。那就是我:-)嗨,你找到答案了吗?谢谢,我在运行测试时仍然会遇到同样的错误。
Cypress.Commands.add("getStore", () => {
return cy.window().its("app.$store")
.then(appStore =>cy.wrap(appStore));
});