我正在努力向 cypress 中的组件添加测试,我想知道是否可以访问测试组件的功能或数据。
您可以通过以下方式访问组件方法:
// 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
});
});