old*_*eyg 0 cucumber cypress cypress-cucumber-preprocessor 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。
任何帮助表示赞赏。
@Tiana 是正确的,但此外您已经supportFile: false在配置中进行了设置,因此您的导入support/commands.ts将永远不会被使用。
赛普拉斯.config.ts
export default defineConfig({
...
e2e: {
specPattern: "**/*.feature",
supportFile: false, <-- don't do this if you want to use the support file
setupNodeEvents,
},
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
274 次 |
| 最近记录: |