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

And step not being recognised as a step in feature file #88

Closed
bgibb95 opened this issue Aug 31, 2022 · 5 comments
Closed

And step not being recognised as a step in feature file #88

bgibb95 opened this issue Aug 31, 2022 · 5 comments

Comments

@bgibb95
Copy link

bgibb95 commented Aug 31, 2022

πŸ‘“ What did you see?

And step not being recognised as a step in feature file.

βœ… What did you expect to see?

And steps found in TypeScript file and no warning messages.

πŸ“¦ Which tool/library version are you using?

Cucumber VS Code extension - v1.2.11
VS Code - v1.70.2
macOS Monterey - v12.5.1 (21G83)

 "devDependencies": {
    "@cypress/browserify-preprocessor": "^3.0.1",
    "@cypress/code-coverage": "^3.10.0",
    "@cypress/webpack-preprocessor": "^5.5.0",
    "@types/node": "^15.3.0",
    "cypress": "^8.6.0",
    "cypress-cucumber-preprocessor": "^4.2.0",
    "cypress-file-upload": "^5.0.8",
    "cypress-iframe": "^1.0.1",
    "typescript": "^4.1.3"
  }

πŸ”¬ How could we reproduce it?

testing/e2e/cypress/integration/change-password.feature

Screenshot 2022-08-31 at 2 49 12 PM

testing/e2e/cypress/integration/change-password/change-password.ts

Screenshot 2022-08-31 at 2 49 47 PM

πŸ“š Any additional context?

settings.json:

"cucumber.glue": ["**/e2e/cypress/integration/**/*.ts"],
"cucumber.features": ["**/e2e/cypress/integration/**/*.feature"]

This text was originally generated from a template, then edited by hand. You can modify the template here.

@pillsilly
Copy link

pillsilly commented Sep 1, 2022

me too , I even tried given the concrete path to test if my expression was problematic -- but same results 😒

@aslakhellesoy
Copy link
Contributor

The Gherkin language has the step keywords Given, When , Then, And and But, but Cucumber only defines the methods Given, When and Then for defining step definitions.

I didn't know Cypress exposes And and But - this is a deviation from the Cucumber standard.

You should be able to rename your And step defintions to Given, When or Then (whichever they represent). They should still be matched even if your Gherkin document uses And.

We could of course add support for recognising And and But in step definitions, but I am not very keen on doing that - it would perpetuate the use of this antipattern.

I'd rather add a note in the docs that Cypress users should avoid using these keywords. Would that work for you?

@aslakhellesoy aslakhellesoy transferred this issue from cucumber/vscode Sep 1, 2022
@bgibb95
Copy link
Author

bgibb95 commented Sep 2, 2022

Thanks for the response and explanation. I had a look at the Cucumber documentation and it seems that Cucumber does recognise And and But keywords, and also mentions them as a solution to an anti-pattern.

Cucumber Conjunction Steps
Screenshot 2022-09-02 at 9 33 30 AM

It seems that there could be value in adding support for And and But in step definitions, but I understand if we prefer not to.

@aslakhellesoy
Copy link
Contributor

The And and But keywords are only recognised in Gherkin. They are not recognised in step definitions. I have submitted an issue requesting that these two keywords be removed from cypress-cucumber-preprocessor: badeball/cypress-cucumber-preprocessor#821

/cc @badeball

@aslakhellesoy
Copy link
Contributor

I'm closing this as I am convinced the fix should be in cypress-cucumber-preprocessor (removing these keywords from the step definition API)

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