简体   繁体   English

如何创建一个通用步骤定义文件夹以供 cypress/cucumber 中的 all.feature 文件使用?

[英]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.

相关问题 如果我使用 cypress-cucumber,是否必须为每个特征文件创建 Step definition 文件夹? - Do I have to create Step definition folder for each feature file if I am using cypress-cucumber? 如何在cypress Cucumber中编写可以被Given、When、Then等使用的通用步骤定义 - How to write a common step definition which can be used by Given, When, Then etc. in cypress Cucumber 如何在Cucumber中创建和使用通用功能文件? - How do you create and use common feature files in Cucumber? cypress cucumber - 如何识别调用步骤定义的功能文件? - cypress cucumber - How to identify the which feature file calling step definition? 赛普拉斯黄瓜 - 如何按顺序运行我的步骤? - Cypress Cucumber - How do I make my steps run in order? 如何使用 Cypress 最新版本 (10.2.20) 访问黄瓜中的功能文件 - How to access feature files in cucumber using Cypress latest version (10.2.20) 如何为cucumber-js中的每个特征文件指定步骤定义文件? - How can I specify step definition file for each feature file in cucumber-js? 我在哪里可以定义赛普拉斯的所有测试用例中使用的公共变量 - - Where can i define common variables used in all test cases for cypress - 如何使用 WebStorm 在 TypeScript 而不是 JavaScript 中创建 Cucumber 步骤定义文件? - How can I use WebStorm to create a Cucumber step definition file in TypeScript instead of JavaScript? 如Ruby Cucumber文档中所述,如何合并Cucumber.js中的步骤? - How can I combine steps in Cucumber.js as described in the Ruby Cucumber documentation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM