简体   繁体   中英

My step definitions are not being picked in Cypress

My current project tree for cypress looks something like this:

├── cypress

│   ├── OtherProjectFolder

│   │   ├── frontend
│   │   │   └── TestUI.feature

│   ├── pages_objects
│   │   ├── mainPage.js

│   └── step_definitions
│       │   └── Testui.js

│   ├── e2e

│   │   ├── backend
│   │   │   └── TestBackend.feature

│   ├── pages_objects
│   │   ├── backendPage.js

│   └── step_definitions
│       │   └── TestBackend.js

Essentially I want to define all my step definitions in a different director, and all my page objects in a different directory, because I have many project to automate.

Here is my current cucumber preprocessor look like in package.json:

"cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": false,
    "step_definitions": "cypress/e2e"
  }

If I change the path of the stepsDefinition to "cypress/OtherProjectFolder", this time it does not picked the steps in e2e. If I just type "cypress" I get this error. Please check attached screenshot. I'm wondering if there is a way to make stepDefinitions global? 在此处输入图像描述

try:

  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": false,
    "stepDefinitions": "cypress/your_folder_name/*.js"
  }

you can of course add more path after that. Good to look at: https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/step-definitions.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM