Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't define feature files in an arbitrary location #1225

Closed
3 tasks done
ameduza opened this issue Aug 20, 2024 · 4 comments
Closed
3 tasks done

Can't define feature files in an arbitrary location #1225

ameduza opened this issue Aug 20, 2024 · 4 comments

Comments

@ameduza
Copy link

ameduza commented Aug 20, 2024

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

badeball added a commit that referenced this issue Sep 25, 2024
badeball added a commit that referenced this issue Sep 26, 2024
@badeball
Copy link
Owner

This has been fixed with v21.0.0.

@ameduza
Copy link
Author

ameduza commented Oct 2, 2024

Hi @badeball , thanks for the fix. For some reason it doesn't work on my side. When I use the same project I provided I'm still getting an error. This time it fails on another level, but also related to folder structure from what I can see.
Here is what I get in headless mode;

Running:  duckduckgo.feature                                                              (1 of 1)
X [ERROR] Failed to create output directory: mkdir C:\Users\AlexanderMaximov\AppData\Roaming\Cypress\cy\production\projects\e2e-4cfc8e3388eddd586614e75c5cc1800e\bundles\P:: The filename, directory name, or volume label syntax is incorrect.


Oops...we found an error preparing this test file:

  > ..\_features\duckduckgo.feature

The error was:

Error: Build failed with 1 error:
error: Failed to create output directory: mkdir C:\Users\AlexanderMaximov\AppData\Roaming\Cypress\cy\production\projects\e2e-4cfc8e3388eddd586614e75c5cc1800e\bundles\P:: The filename, directory name, or volume label syntax is incorrect.
    at failureErrorWithLog (P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:1472:15)
    at P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:945:25
    at runOnEndCallbacks (P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:1315:45)
    at buildResponseToResult (P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:943:7)
    at P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:970:16
    at responseCallbacks.<computed> (P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:622:9)
    at handleIncomingPacket (P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:677:12)
    at Socket.readFromStdout (P:\cypress-cucumber-featuresFailure\e2e\node_modules\esbuild\lib\main.js:600:7)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:domain:488:12)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Socket.Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.

If I move feature on the same level as cypress and update cypress.config.ts - then all is good like on the previous version.

Tried different Cypress versions - still the same.

Can you please confirm it is really working on your side?

@badeball
Copy link
Owner

badeball commented Oct 2, 2024

Can you please confirm it is really working on your side?

I tested it, albeit not on windows, let alone windows with cache & project on different drives. This is a use case I'm not going to invest time in, but you can try to create another issue outlining a minimal reproducible example and I can tag it with "help wanted".

@ameduza
Copy link
Author

ameduza commented Oct 3, 2024

@badeball , my apologies - it now runs on my side as well. I didn't delete package-lock.json on my side and Cypress version was locked to v12.14.0. So after I resolved this and really used latest Cypress version (13.15.0) it started to work with no issues! Will try to see if I can upgrade our test solution to the latest version.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants