Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Scenario is incorrectly interpreted as Scenario Outline when using Gherkin in PT-BR #5070

Closed
@gguto

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

  1. In a .feature file that contains both Cenário (Scenario) and Esquema 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 |
  1. Run the command to execute the test using grep:
npx codeceptjs run --debug --grep "@Executar"
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /