[英]How can I create a common steps definition folder to be used by all .feature files in cypress/cucumber?
I have a framework built using cucumber on top of cypress (javascript).我有一个在柏树(javascript)之上使用 cucumber 构建的框架。
I'm using this version: cypress-cucumber-preprocessor: ^4.0.1我正在使用这个版本: cypress-cucumber-preprocessor: ^4.0.1
According to the docs (confirmed by the behavior), it is mandatory for cucumber to have a folder at the same level and with the same name as the feature file, so cucumber knows where to look for the steps.根据文档(由行为确认),cucumber 必须具有与功能文件同级且同名的文件夹,因此 cucumber 知道在哪里查找步骤。 As such, my file structure is:
因此,我的文件结构是:
-integration
---myApp
-----users
-------login.feature
-------login
---------login.steps.js
-------signup.feature
-------signup
---------signup.steps.js
-----someotherentity
-------foo.feature
-------foo
---------foo.steps.js
So login.feature, needs a folder at the same level called "login" where I store the step definitions and so on.所以 login.feature 需要一个名为“login”的文件夹,我在其中存储步骤定义等。
All those feature files need these 2 steps for example例如,所有这些功能文件都需要这两个步骤
Given('I visit the homepage', () => {cy.visit('https://myhomepage.com)})
When('I click Ok', () =>{cy.get('#proceedButton').click()})
I have those 2 steps defined in all 3 files so It would make sense to have a common folder for common step definitions regarding navigation, clicks, etc.我在所有 3 个文件中都定义了这 2 个步骤,因此为有关导航、点击等的常见步骤定义创建一个通用文件夹是有意义的。
How can I do that here?我怎么能在这里做到这一点?
Please, have a look here:请看这里:
https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#cypress-configuration https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#cypress-configuration
In case you decide to change the Cypress Cucumber Preprocessor Style pattern you must pay attention to the corresponding information in package.json file如果您决定更改赛普拉斯 Cucumber 预处理器样式模式,您必须注意 package.json 文件中的相应信息
For example: "cypress-cucumber-preprocessor": { "commonPath": "common", "stepDefinitions": "step_definitions" }例如:“cypress-cucumber-preprocessor”:{“commonPath”:“common”,“stepDefinitions”:“step_definitions”}
allows you to have a separate folder for common step definitions允许您为常用步骤定义创建一个单独的文件夹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.