cypress-cucumber-preprocessor icon indicating copy to clipboard operation
cypress-cucumber-preprocessor copied to clipboard

Can't define feature files in an arbitrary location

Open ameduza opened this issue 1 year ago • 0 comments
trafficstars

Current behavior

I like to define project structure like the below so I can access .feature files from different frameworks implementation (UI on Cypress, API on Java etc.):

.
├── _features/
│   ├── feature1.feature
│   └── feature2.feature
├── api/
│   └── api project goes here...
└── e2e/
    ├── cypress/
    │   └── steps/
    │       └── steps-definitions.ts
    ├── cypress.config.ts
    ├── package.json
    └── tsconfig.json

When I define specPattern: "../_features/**/*.feature" Cypress clearly finds all the features, but then preprocessor fails with error:


  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.13.0                                                                        │
  │ Browser:        Electron 118 (headless)                                                        │
  │ Node Version:   v20.14.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          1 found (duckduckgo.feature)                                                   │
  │ Searched:       ../_features/**/*.feature                                                      │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  duckduckgo.feature                                                              (1 of 1)
X [ERROR] P:\cypress-cucumber-featuresFailure\_features\duckduckgo.feature is not inside P:\cypress-cucumber-featuresFailure\e2e [plugin feature]

    node_modules/@badeball/cypress-cucumber-preprocessor/dist/step-definitions.js:56:14:
      56 │         throw new Error(`${filepath} is not inside ${projectRoot}`);
         ╵               ^

    at getStepDefinitionPatterns (P:\cypress-cucumber-featuresFailure\e2e\node_modules\@badeball\cypress-cucumber-preprocessor\dist\step-definitions.js:56:15)

I see this handler in step-definitions.js so seems it was done intentionally, but still - I hope this limitation could be re-worked

function getStepDefinitionPatterns(configuration, filepath) {
    const projectRoot = configuration.cypress.projectRoot;
    if (!(0, is_path_inside_1.default)(filepath, projectRoot)) {
        throw new Error(`${filepath} is not inside ${projectRoot}`);
    }

Desired behavior

I'd like to be able to define folder with .feature files in any location. This works fine in Java Cucumber project for me. Found similar problem description in issue 395, but the provided workaround not working for me.

Test code to reproduce

Please find project zip attached. This is super minimum structure that clearly reproduces the issue. cypress-cucumber-featuresFailure.zip

Versions

  • Cypress version: 13.13.3 (latest)
  • Preprocessor version: 20.1.2 (latest)
  • Node version: 20.14.0

Checklist

ameduza avatar Aug 20 '24 20:08 ameduza