Cypress VUE 组件测试,组件访问方法

问题描述 投票:0回答:1

我正在努力向 cypress 中的组件添加测试,我想知道是否可以访问测试组件的功能或数据。

vue.js vuejs2 cypress
1个回答
0
投票

您可以通过以下方式访问组件方法:

// if MyComponent.vue exposes a method called 'doSomething':

it('accesses the component methods', () => {
  cy.mount(MyComponent).then((comp) => {
    const { wrapper } = comp;
    wrapper.componentVM.doSomething();

    // rest of your test
  });
});

© www.soinside.com 2019 - 2024. All rights reserved.