我们正在用公司设计系统中的组件替换我们的定制Reaction组件. 这些都是Web组件,它被做成了一个Reaction包装器,以使它们在Reaction中工作.
在我们的应用程序中,元素是这样呈现的:
<custom-button title="" data-test-id="save" disabled mode="primary">
#shadow-root
<button data-mode="primary" size="small" type="button" title="" disabled>Save</button>
</custom-button>
在Cypress ,我试着判断它是否被禁用,如下所示:
cy.getByTestId('save').should('be.disabled'); //Doesn't work, but its the way I want to do it
cy.getByTestId('save').find('button').should('be.disabled'); // Works
第一种方法不起作用,但这是我想要做的,因为这是我们今天所有测试的工作方式. 我希望不得不采用第二种方式,因为这意味着我们必须处理我们设计系统中的按钮--与常规按钮不同.
有人知道为什么第一种方法行不通吗?即使<custom-button>
在DOM中应用了disabled
属性?