![](/img/trans.png)
[英]Do I have to create Step definition folder for each feature file if I am using cypress-cucumber?
[英]How can I create a common steps definition folder to be used by all .feature files in cypress/cucumber?
我有一个在柏树(javascript)之上使用 cucumber 构建的框架。
我正在使用这个版本: cypress-cucumber-preprocessor: ^4.0.1
根据文档(由行为确认),cucumber 必须具有与功能文件同级且同名的文件夹,因此 cucumber 知道在哪里查找步骤。 因此,我的文件结构是:
-integration
---myApp
-----users
-------login.feature
-------login
---------login.steps.js
-------signup.feature
-------signup
---------signup.steps.js
-----someotherentity
-------foo.feature
-------foo
---------foo.steps.js
所以 login.feature 需要一个名为“login”的文件夹,我在其中存储步骤定义等。
例如,所有这些功能文件都需要这两个步骤
Given('I visit the homepage', () => {cy.visit('https://myhomepage.com)})
When('I click Ok', () =>{cy.get('#proceedButton').click()})
我在所有 3 个文件中都定义了这 2 个步骤,因此为有关导航、点击等的常见步骤定义创建一个通用文件夹是有意义的。
我怎么能在这里做到这一点?
请看这里:
https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#cypress-configuration
如果您决定更改赛普拉斯 Cucumber 预处理器样式模式,您必须注意 package.json 文件中的相应信息
例如:“cypress-cucumber-preprocessor”:{“commonPath”:“common”,“stepDefinitions”:“step_definitions”}
允许您为常用步骤定义创建一个单独的文件夹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.