使用vue cli在cypress中获取Vuex存储引用
在运行e2e测试时,我将按照教程在cypress中获取vuex存储 当我使用vue cli(@vue/cli 4.3.1)时。 在这个设置中,我没有app.js,而是main.js 但是,如果我将所需的代码放在main.js中,它将不起作用:使用vue cli在cypress中获取Vuex存储引用,cypress,vue-cli-3,Cypress,Vue Cli 3,在运行e2e测试时,我将按照教程在cypress中获取vuex存储 当我使用vue cli(@vue/cli 4.3.1)时。 在这个设置中,我没有app.js,而是main.js 但是,如果我将所需的代码放在main.js中,它将不起作用: /** * Start APP */ const app = new Vue({ router, render: h => h(App), }).$mount('#app'); if (window.Cypress) {
/**
* Start APP
*/
const app = new Vue({
router,
render: h => h(App),
}).$mount('#app');
if (window.Cypress) {
console.log('Running in Cypress');
// only available during E2E tests
window.app = app;
} else {
console.log('NOT Running in Cypress');
}
如果我从cypress运行它,我不会将main.js中的任何内容记录到控制台
在cypress,当我想去商店的时候
cy.window().its('app.$store')
我得到一个错误:
Timed out retrying: cy.its() errored because the property: app does not exist on your subject.
如何使用vue cli使其运行