automation - 在 Cypress 中运行时如何将某些测试或文件组合在一起?
问题描述
我目前正在运行 Cypress,其中有文件夹,其中有针对不同应用程序的测试。我有一个名为“smhw-qa”的文件夹,其中包含此特定应用程序的子文件夹和测试文件。
该目录apps
将来也将包括其他应用程序。
我想做的事
为了避免必须运行每个测试来运行,我希望只运行这个特定的文件夹。文件夹的位置是这样的:
'cypress/integration/apps/smhw-qa'
随着时间的推移,将会有更多的文件夹和测试添加到apps
目录中。
我熟悉如何运行特定文件,因此执行以下工作:
npx cypress run --spec 'cypress/integration/apps/smhw-qa/banners_promos_global/global_search.js'
当我使用命令时,如何向赛普拉斯指定要运行的文件夹npx cypress -run
?
我已经尝试过的
要运行我尝试的特定测试文件:
npx cypress run --project 'cypress/integration/apps/smhw-qa'
但这反而提供了一个错误:
Can't run because no spec files were found.
We searched for any files inside of this folder:
/Users/jaswindersingh/Documents/cypress-automation/automation/cypress/integration/apps/smhw-qa/cypress/integration
通过它们的文件夹运行特定的测试集对我来说会容易得多,并且例如在我们的 CI 平台上运行特定的测试套件时会节省时间。我也不需要指定单个文件,因为这很耗时。
这也意味着我可以拆分我的测试并在不同的机器上运行它们
我是否需要将任何内容放入我的测试文件中,或者在cypress.json
其他任何内容中进行修改,或者这可以通过终端来实现吗?我必须改用哪些选项?
谢谢
解决方案
我认为线索在错误消息中,你打电话
cypress/integration/apps/smhw-qa
并且错误消息显示
cypress/integration/apps/smhw-qa/cypress/integration
所以要使用--project
你需要复制/cypress
每个项目的文件夹的标志,按照这个例子cypress-test-nested-projects
文件夹结构:
package.json
node_modules
src/
clients/
foo/
cypress.json
cypress/
bar/
cypress.json
cypress/
但是,我认为您可能想改用该--spec
标志。如果我理解正确,glob 模式将允许您保留当前的文件夹结构。文档
cypress run --spec 'cypress/integration/apps/smhw-qa/**/*'
推荐阅读
- apache-spark - 哪个更好,创建单独的数据框或引用同名的数据框
- scala - Apache Flink:如何将流下沉到谷歌云存储文件系统
- mysql - 用于检查 JSON 数组中是否存在至少一项的 SQL 正则表达式
- elasticsearch - Elasticsearch - 从 6.7 升级到 7.0 后,此搜索不会返回正确的结果
- domain-driven-design - 在事件驱动的微服务中,如何使用旧数据更新私有数据库
- android - 此会话的初始化功能不可用,在 google Ads 中
- knockout-validation - 在提交时验证输入字段
- postgresql - 搜索非散列数据
- javascript - 将平面列表转换为父子树
- ios - 如何检查用户是否在firebase中的不同视图控制器中登录