-
-
Notifications
You must be signed in to change notification settings - Fork 750
Description
What are you trying to achieve?
In our .feature
files, we use Gherkin in PT-BR and run the scenarios using grep
. In the latest versions, the execution of Cenário
(Scenario) stopped working. When we add the tag directly to the scenario or to the feature, the scenarios are not included in the test suite execution — only Esquema do Cenário
(Scenario Outlines) are executed.
What do you get instead?
We expect to be able to run a Cenário
(Scenario) test again, which is already part of the test suite and mapped in our .feature files.
Reproduction steps
- In a .feature file that contains both
Cenário
(Scenario) andEsquema do Cenário
(Scenario Outlines), using a language other than English (e.g., PT-BR), add a tag:
# language: pt
@Executar
Funcionalidade: Exemplo de execução das funcionalidades de um sistema
Cenário: Funcionalidade um
Dado que inicio meu teste
Quando faço algo
Então acontece alguma coisa
Esquema do Cenário: Funcionalidade dois com esquema do cenário
Dado que estou com o usuário "<usuário>"
Quando faço algo com o usuário
Então acontece alguma coisa
Exemplos:
| usuário |
| Um |
| Dois |
- Run the command to execute the test using grep:
npx codeceptjs run --debug --grep "@Executar"
- At this point, only the tests defined in Scenario Outlines are added to the execution.
We debugged the code and identified the possible location of the issue, as shown below:
In the file .../codeceptjs/lib/mocha/gherkin.js
, at line 110, there is an if statement responsible for differentiating between a Scenario
and a Scenario Outline
.
When using PT-BR, specifically in the following snippet:
currentLanguage.contexts.ScenarioOutline.includes(child.scenario.keyword)
the value of currentLanguage.contexts.ScenarioOutline
is Esquema do Cenário
.
The issue is that when checking a Cenário
(Scenario), the use of includes causes the condition to also evaluate as true (since Cenário
is contained within Esquema do Cenário
). As a result:
The code incorrectly enters the if
branch.
It then proceeds to the for
loop expecting examples
.
Since a plain Scenario
does not have examples, the execution hits the continue
at line 142.
This prevents the code from reaching the if
at line 145, which is the correct branch for handling Scenario
.
Possible solution
At line 110, instead of using includes, use strict equality (===):
if (child.scenario && (currentLanguage
? currentLanguage.contexts.ScenarioOutline === child.scenario.keyword
: child.scenario.keyword === 'Scenario Outline')) {
Details
CodeceptJS version: 3.7.3
Helper: Playwright
NodeJS version: 22.18.0
Operating System: Ubuntu 22.04