From 0f21609b9d2b79eb3ddc205011c2c0e24080ab18 Mon Sep 17 00:00:00 2001 From: kobenguyent <7845001+kobenguyent@users.noreply.github.com> Date: Tue, 19 Aug 2025 07:22:37 +0000 Subject: [PATCH] fix: 5070 issue --- lib/mocha/gherkin.js | 2 +- test/data/sandbox/i18n/codecept.bdd.pt-br.js | 19 ++++++++++++++ .../i18n/features/examples.pt-br.feature | 19 ++++++++++++++ .../step_definitions/my_steps.pt-br.js | 25 +++++++++++++++++++ test/runner/bdd_test.js | 17 ++++++++++++- 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 test/data/sandbox/i18n/codecept.bdd.pt-br.js create mode 100644 test/data/sandbox/i18n/features/examples.pt-br.feature create mode 100644 test/data/sandbox/i18n/features/step_definitions/my_steps.pt-br.js diff --git a/lib/mocha/gherkin.js b/lib/mocha/gherkin.js index bcb3e63d8..904d51a9b 100644 --- a/lib/mocha/gherkin.js +++ b/lib/mocha/gherkin.js @@ -107,7 +107,7 @@ module.exports = (text, file) => { ) continue } - if (child.scenario && (currentLanguage ? currentLanguage.contexts.ScenarioOutline.includes(child.scenario.keyword) : child.scenario.keyword === 'Scenario Outline')) { + if (child.scenario && (currentLanguage ? currentLanguage.contexts.ScenarioOutline === child.scenario.keyword : child.scenario.keyword === 'Scenario Outline')) { for (const examples of child.scenario.examples) { const fields = examples.tableHeader.cells.map(c => c.value) for (const example of examples.tableBody) { diff --git a/test/data/sandbox/i18n/codecept.bdd.pt-br.js b/test/data/sandbox/i18n/codecept.bdd.pt-br.js new file mode 100644 index 000000000..0eb2d6020 --- /dev/null +++ b/test/data/sandbox/i18n/codecept.bdd.pt-br.js @@ -0,0 +1,19 @@ +exports.config = { + tests: './*_no_test.js', + timeout: 10000, + output: '../output', + helpers: { + BDD: { + require: '../support/bdd_helper.js', + }, + }, + gherkin: { + features: './features/examples.pt-br.feature', + steps: ['./features/step_definitions/my_steps.pt-br.js'], + }, + include: {}, + bootstrap: false, + mocha: {}, + name: 'sandbox', + translation: 'pt-BR', +} diff --git a/test/data/sandbox/i18n/features/examples.pt-br.feature b/test/data/sandbox/i18n/features/examples.pt-br.feature new file mode 100644 index 000000000..9c1523f58 --- /dev/null +++ b/test/data/sandbox/i18n/features/examples.pt-br.feature @@ -0,0 +1,19 @@ +#language: pt + +@i18n +Funcionalidade: Teste de Cenário e Esquema do Cenário + + Cenário: Cenário simples + Dado que inicio meu teste + Quando faço algo + Então acontece alguma coisa + + @i18n + Esquema do Cenário: Cenário com exemplos + Dado que estou com o usuário "" + Quando faço algo com o usuário + Então acontece alguma coisa + Exemplos: + | usuário | + | Um | + | Dois | diff --git a/test/data/sandbox/i18n/features/step_definitions/my_steps.pt-br.js b/test/data/sandbox/i18n/features/step_definitions/my_steps.pt-br.js new file mode 100644 index 000000000..b80224505 --- /dev/null +++ b/test/data/sandbox/i18n/features/step_definitions/my_steps.pt-br.js @@ -0,0 +1,25 @@ +const I = actor() + +Given('que inicio meu teste', function () { + // Simula início do teste +}) + +When('faço algo', function () { + // Simula ação +}) + +Then('acontece alguma coisa', function () { + // Simula verificação +}) + +Given('que estou com o usuário {string}', function (usuario) { + // Simula usuário +}) + +When('faço algo com o usuário', function () { + // Simula ação com usuário +}) + +Then('acontece alguma coisa', function () { + // Simula verificação +}) diff --git a/test/runner/bdd_test.js b/test/runner/bdd_test.js index ae0fb37fd..863fe9fa4 100644 --- a/test/runner/bdd_test.js +++ b/test/runner/bdd_test.js @@ -356,7 +356,6 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => { it('should run feature files in NL', done => { exec(config_run_config('codecept.bdd.nl.js') + ' --steps --grep "@i18n"', (err, stdout, stderr) => { - console.log(stdout) stdout.should.include('On Gegeven: ik heb een product met een prijs van 10$ in mijn winkelwagen') stdout.should.include('On En: de korting voor bestellingen van meer dan $20 is 10 %') stdout.should.include('On Wanneer: ik naar de kassa ga') @@ -373,5 +372,21 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => { done() }) }) + + it('should run feature files in PT-BR', done => { + exec(config_run_config('codecept.bdd.pt-br.js') + ' --steps --grep "@i18n"', (err, stdout, stderr) => { + stdout.should.include('On Dado: que inicio meu teste') + stdout.should.include('On Quando: faço algo') + stdout.should.include('On Então: acontece alguma coisa') + stdout.should.include('On Dado: que estou com o usuário "um"') + stdout.should.include('On Quando: faço algo com o usuário') + stdout.should.include('On Dado: que estou com o usuário "dois"') + stdout.should.include('Cenário simples') + stdout.should.include('Cenário com exemplos') + stdout.should.match(/OK \| 3 passed/) + assert(!err) + done() + }) + }) }) })