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

Bug report: An alternation can not be used inside an optional. #142

Closed
nklowns opened this issue Jan 26, 2023 · 2 comments · Fixed by cucumber/cucumber-expressions#260
Closed

Comments

@nklowns
Copy link

nklowns commented Jan 26, 2023

👓 What did you see?

[Info  - 19:03:16] Reindexing file://c:\develop\HIDDEN
[Info  - 19:03:16] * Found 63 feature file(s) in ["tests/e2e/specs/**/*.feature"]
[Info  - 19:03:16] * Found 1135 steps in those feature files
[Info  - 19:03:18] * Found 62 glue file(s) in ["tests/e2e/specs/**/*.js"]
[Info  - 19:03:18] * Found 0 parameter types in those glue files
[Info  - 19:03:18] * Found 463 step definitions in those glue files
[Error - 19:03:18] * Step Definition errors: Error: This Cucumber Expression has a problem at column 21:

entro no detalhe d(a/o) {string}
                    ^
An alternation can not be used inside an optional.
You can use '\/' to escape the the '/'
    at mT (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:67:79659)
    at e0 (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:1105)
    at Gk (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2717)
    at bT (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2874)
    at c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2484
    at Gk (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2717)
    at bT (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2874)
    at Bk (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2005)
    at Gk (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2717)
    at bT (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2874)
    at c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2484
    at ic.parse (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:2376)
    at new Mi (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:5199)
    at ma.createExpression (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:84:11734)
    at c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:448:748
    at Lf.eachStepDefinitionExpression (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:445:1237)
    at Af.build (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:448:695)
    at bc.<anonymous> (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:454:18598)
    at Generator.next (<anonymous>)
    at u (c:\Users\cloud\.vscode\extensions\cucumberopen.cucumber-official-1.7.0\out\extension.js:454:11308)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

✅ What did you expect to see?

📦 Which tool/library version are you using?

Cucumber plugin: v1.7.0
VS code: 1.74.3

🔬 How could we reproduce it?

Steps to reproduce the behavior:

  1. Install Cucumber extension v1.7 onto latest VS Code
  2. Create any feature file
  3. Have two Scenario:
# language: pt

Funcionalidade: XYZ

    Cenário: Editar XYZ
        Quando entro no detalhe da "XYZ"

    Cenário: Editar ZYX
        Quando entro no detalhe do "ZYX"
  1. Create any spec file
  2. Have one step definition:
import { When } from 'cypress-cucumber-preprocessor/steps'
const { wait } = cy

When('entro no detalhe d(a/o) {string}', () => {
  wait('@apisRequests')
})

📚 Any additional context?


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

@kieran-ryan
Copy link
Member

kieran-ryan commented Dec 2, 2023

@nklowns, modifying your step definition from d(a/o) to d/da/do, d(a)/do or d(a)/d(o) will resolve the issue and match your steps as expected - see alternative text use in cucumber expressions.

import { When } from 'cypress-cucumber-preprocessor/steps'
const { wait } = cy

When('entro no detalhe da/do {string}', () => {
  wait('@apisRequests')
})
Screenshot 2023-12-02 at 23 44 17

@kieran-ryan
Copy link
Member

Thank you very much for raising @nklowns. This is expected behaviour of Cucumber Expressions; however arising from this issue, I have raised a pull request to improve the error message. If you have any feedback on it, please let us know. You can also raise a feature request to that repository if you would like support to be added for using alternations inside optionals.

An alternation can not be used inside an optional
If you did not mean to use an alternation you can use '\\/' to escape the '/'. Otherwise rephrase your expression or consider using a regular expression instead.

@nklowns, modifying your step definition from d(a/o) to d/da/do, d(a)/do or d(a)/d(o) will resolve the issue and match your steps as expected

If changing to the above doesn't meet your use case and you had a different intention, please advise and will see if an appropriate solution can be provided.

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

Successfully merging a pull request may close this issue.

2 participants