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

Unable to find the step defs when using custom directory structure #682

Closed
salvag-ntt opened this issue Mar 24, 2022 · 3 comments
Closed

Comments

@salvag-ntt
Copy link

Current behavior

Using a custom directory structure (i.e. not with typical cypress/integration/features folder) causes the plugin not to be able to find the step defs, even following the instructions on the configuration for the custom directory structure

Desired behavior

Step defs should be found in a project with a custom directory structure

Longer description

I need to support a custom directory structure on my project. I am splitting the directory structure this way

package.json
src/
testing/
   ---> acceptance/
   ---> accessibility/
   ---> performance/
   ---> cypress.acceptance.json
   ---> cypress.accessibility.json
   ---> cypress.performance.json

Where the cypress.X.json files are the Cypress configuration files that will act as the cypress.json for each testing folder. To manage this I am adding some scripts to my package.json to make things easier

 "scripts": {
   ...
    "test:acceptance": "npx cypress run --config-file test/cypress.acceptance.json",
    "test:performance": "npx cypress run --config-file test/cypress.performance.json",
    "test:accessibility": "npx cypress run --config-file test/cypress.accessibility.json",
   ...
 }

If we focus on the acceptance testing for a moment, the Cypress configuration (test/cypress.acceptance.json) looks something like this (yes I had to override all the defaults to make Cypress happy!)

{
    "baseUrl": "http://localhost:3000/",
    "video": true,
    "cypress-cucumber-preprocessor": {
        "nonGlobalStepDefinitions": true,
        "nonGlobalStepBaseDir": "test/acceptance/integration"
    },
    "testFiles": "**/*.feature",
    "integrationFolder": "test/acceptance/integration",
    "fixturesFolder": "test/acceptance/fixture",
    "screenshotsFolder": "test/acceptance/screenshots",
    "videoFolder": "test/acceptance/videos",
    "pluginsFile": "test/acceptance/plugins/index.js"
}

From what I can tell this seems to be doable and in the docs https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#configuration they give the options above in the "cypress-cucumber-preprocessor" where they also suggest the nonGlobalStepBaseDir should point at the same path as the integration folder (which I have done... except that all of this doesn't work. The error I am getting is the step definitions are not found (will post only one of the failed test for shortness, the others are the same)

  Running:  features/product-catalogue/product-catalog.feature                              (4 of 8)


  Product Catalog
    1) A customer is able to see the product catalog
    2) The product catalog displays the navigation bar
    3) The catalogue page view defaults to grid on mobile


  0 passing (2s)
  0 pending
  3 failing

  1) Product Catalog
       A customer is able to see the product catalog:
     Error: Step implementation missing for: products are available on the system
      at Context.resolveAndRunStepDefinition (http://localhost:3000/__cypress/tests?p=test/acceptance/integration/features/product-catalogue/product-catalog.feature:12789:11)
      at Context.eval (http://localhost:3000/__cypress/tests?p=test/acceptance/integration/features/product-catalogue/product-catalog.feature:12104:35)

Note that the internal directory structure used to work before when it was inside the traditional cypress/integration/features folder. At the end of the day I have just renamed things around and pushed one level down to test/acceptance/integration/features.

From what I can tell it's the plugin not able to get the base folder for the non-global step definitions, but I can't see why.

Test code to reproduce

I will try to create a specific repo to reproduce the issue, as I am under confidentiality I can't share the repo I am working on directly. But just to be clear, you should be able to repro this behaviour if you just follow the above description. It should have the necessary config I have used. Please do let me know if something more is needed

Versions

  • Cypress version: 9.5
  • Preprocessor version: 4.3.1
  • Node version:14.18.1
@richardszanyi-kasa
Copy link

+1, I would want to have the following folder structure but I cannot do that as of right now.

package.json
cypress/
integration/
e2e/
   ---> features/
   ---> stepDefinitions/
           ---> aws/
           ---> common.js

So far I've only gotten to the point where I can tell cypress where feature files are and move the integration folder out of the cypress folder. However, I would like to point to the step definitions folder and let it read everything inside it.

No configuration in the stepDefinitions property works unfortunately. :(

@badeball
Copy link
Owner

Hi @salvag-ntt and @richardszanyi-kasa

I've been contributing a bit to this project for some time and have also taken the time to re-write it in TypeScript, add more thorough test coverage and re-wamped the way step definitions are resolved. I'm trying satisfy user requirements broadly without bloating configuration options and want to see if we can get this case to work as well.

I will try to create a specific repo to reproduce the issue, as I am under confidentiality I can't share the repo I am working on directly. But just to be clear, you should be able to repro this behaviour if you just follow the above description. It should have the necessary config I have used. Please do let me know if something more is needed

One of us must necessarily do it and I see no reason why it should always be me, so I would ask you to do exactly that. Please compose a minimal example consisting of 2 or more feature files and step definitions where you want them, then I'll see if I can get it to work with my fork.

@badeball
Copy link
Owner

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.

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

3 participants