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

[filepath] not including subfolders in resolution #1195

Closed
3 tasks done
Aryndel opened this issue Jun 7, 2024 · 2 comments
Closed
3 tasks done

[filepath] not including subfolders in resolution #1195

Aryndel opened this issue Jun 7, 2024 · 2 comments

Comments

@Aryndel
Copy link

Aryndel commented Jun 7, 2024

Current behavior

If I configure custom stepDefinitions, the [filepath] expression is resolving only to the cypress/e2e CAP folder and ignoring any subfolders that the feature file appears in

For example, I have a feature file located at cypress\e2e\smoke\duckduckgo.feature, and a steps file located at cypress\e2e\smoke\duckduckgo.ts

Using the following settings in my package.json (this is the "default" specified in step-definitions.md):

"stepDefinitions": [
  "cypress/e2e/[filepath]/**/*.{js,ts}",
  "cypress/e2e/[filepath].{js,ts}",
  "cypress/support/step_definitions/**/*.{js,ts}"
]

I receive a step resolution error, which seems to be indicating it is resolving [filepath] to cypress\e2e\duckduckgo.{js,ts}, not including the smoke subfolder. Below is the full debug log:

DevTools listening on ws://127.0.0.1:64476/devtools/browser/fc311076-d939-4375-9a84-bf149475a13c
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

====================================================================================================

  (Run Starting)

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


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

  Running:  duckduckgo.feature                                                              (1 of 1)


  duckduckgo.com
    1) visiting the frontpage


  0 passing (252ms)
  1 failing

  1) duckduckgo.com
       visiting the frontpage:
     Error:
Step implementation missing for "I visit duckduckgo.com".

We tried searching for files containing step definitions using the following search pattern templates:

  - cypress/e2e/[filepath]/**/*.{js,ts}
  - cypress/e2e/[filepath].{js,ts}
  - cypress/support/step_definitions/**/*.{js,ts}

These templates resolved to the following search patterns:

  - cypress\e2e\duckduckgo\**\*.{js,ts}
  - cypress\e2e\duckduckgo.{js,ts}
  - cypress\support\step_definitions\**\*.{js,ts}

These patterns matched **no files** containing step definitions. This almost certainly means that you have misconfigured `stepDefinitions`.

You can implement it using the suggestion(s) below.

  When("I visit duckduckgo.com", function () {
    return "pending";
  });

      at Context.eval (https://duckduckgo.com/__cypress/tests?p=cypress\e2e\smoke\duckduckgo.feature:14699:29)




  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                             
   │
  │ Passing:      0                                                                             
   │
  │ Failing:      1                                                                             
   │
  │ Pending:      0                                                                             
   │
  │ Skipped:      0                                                                             
   │
  │ Screenshots:  1                                                                             
   │
  │ Video:        false                                                                         
   │
  │ Duration:     0 seconds                                                                     
   │
  │ Spec Ran:     duckduckgo.feature                                                            
   │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Screenshots)

  -  C:\Projects\TestAutomation\cypress\screenshots\duckduckgo.feature\duckduckgo.com     (1280x720)
      -- visiting the frontpage (failed).png                                                    



====================================================================================================

  (Run Finished)


───┐
  │ ×  duckduckgo.feature                       254ms        1        -        1        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ×  1 of 1 failed (100%)                     254ms        1        -        1        -        -

This issue does NOT occur if I do not specify custom step definition patterns and leave it at the default (again, even though I started with just configuring the "default" step definition patterns in my package.json). It also does NOT occur if I place the files directly in the e2e folder and not in a subfolder

Desired behavior

[filepath] SHOULD resolve to cypress\e2e\smoke\duckduckgo.{js,ts} for this feature file, including its subfolder

Test code to reproduce

https://github.com/Aryndel/cypress-cucumber-test/tree/main

This is nearly identical to the esbuild-ts example, just with custom stepDefinitions and with the duckduckgo files in a subfolder

Versions

  • Cypress version: 13.11.0
  • Preprocessor version: 20.0.6
  • Node version: 18.18.2

Checklist

  • I've read the FAQ.
  • I've read instructions for logging issues.
  • I'm not using cypress-cucumber-preprocessor@4.3.1 (package name has changed and it is no longer the most recent version, see #689).
@badeball
Copy link
Owner

badeball commented Jun 8, 2024

Change cypress/e2e to cypress/e2e/smoke in package.json.

[filepath] SHOULD resolve to cypress\e2e\smoke\duckduckgo.{js,ts} for this feature file, including its subfolder

No. You should read the documentation regarding pairing carefully, especially the part about common ancestor path. If you start adding more features outside of the smoke directory, then your original configuration will start working.

@badeball badeball closed this as completed Jun 8, 2024
@Aryndel
Copy link
Author

Aryndel commented Jun 10, 2024

Thanks. I read that documentation multiple times but that part went over my head. As a temporary solution until more tests are added I just added a dummy feature file in a separate folder.

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