我正在尝试编写一个测试,以确认 a具有使用来自 的基于角色的查询<datalist/>的元素列表。奇怪的是,当我尝试按角色查询时:<option/>@testing-library/cypressoption
cy.findByRole('option')
Run Code Online (Sandbox Code Playgroud)
...我没有返回任何结果:
4000 毫秒后超时重试:无法找到具有“选项”角色的可访问元素
...尽管页面中出现内容:
<datalist id="subjects-list">
<option value="one">one</option>
<option value="two">two</option>
</datalist>
<input list="subjects-list" value=""/>
Run Code Online (Sandbox Code Playgroud)
有没有办法找到这些选项@testing-library/cypress?
wai-aria html-datalist cypress testing-library cypress-testing-library
我有一个反应应用程序,我正在尝试使用 Cypress 进行测试,badeball/cypress-cucumber-preprocessor但testing-library出现错误
cy.findByRole is not a function
Run Code Online (Sandbox Code Playgroud)
这是我当前的设置:
的 e2e 部分cypress.config.ts有两种配置,可以通过注释掉一种并保留另一种来进行测试。第一个(当前配置的)将尝试将测试作为功能文件运行,但会失败。第二个配置使用正常的 cypress 测试,并将显示“testing-library”功能在那里正常工作。
setupNodeEvents()中的函数并不cypress.config.ts完全遵循 badeball/cypress-cucumber-preprocessor 文档中找到的 webpack/ts 示例,因为该示例与 esModuleInterop 设置为 true 时效果不佳,该值在我的应用程序的其他部分中使用,因此此配置这是我为实现这一目标所做的尝试。但我确实测试了该示例配置,但仍然无法使测试库功能正常工作。
我已经设置了脚本,因此您可以使用npm test在 e2e 模式下启动 cypress。
任何帮助表示赞赏。
cucumber cypress cypress-cucumber-preprocessor cypress-testing-library
我有一个无线电元素<input type="radio" name="gender" value="male" />
下面是我的赛普拉斯代码
cy.getAllByRole("radio").first().click()
如何获取 radio 元素的 value 属性?像这样的东西
const radioValue = cy.getAllByRole("radio").first().getValue() //"male"
javascript jquery e2e-testing cypress cypress-testing-library
cy.wait(20 * 1000);
cy.getAllByTestId('test-field-one')
.first()
.within(() => cy.getByTestId('test-field-two'))
.should('contain', 'test');
Run Code Online (Sandbox Code Playgroud)
我目前正在使用上面的代码,但我不喜欢等待。我更喜欢超时值。有谁知道这在柏树中是否可能?
cypress ×4
cucumber ×1
cypress-cucumber-preprocessor ×1
e2e-testing ×1
javascript ×1
jquery ×1
wai-aria ×1