diff --git a/lib/mocha/gherkin.js b/lib/mocha/gherkin.js index 2e4d040fe..bcb3e63d8 100644 --- a/lib/mocha/gherkin.js +++ b/lib/mocha/gherkin.js @@ -107,7 +107,7 @@ module.exports = (text, file) => { ) continue } - if (child.scenario && (currentLanguage ? child.scenario.keyword === currentLanguage.contexts.ScenarioOutline : child.scenario.keyword === 'Scenario Outline')) { + if (child.scenario && (currentLanguage ? currentLanguage.contexts.ScenarioOutline.includes(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/configs/translation/translation_test.js b/test/data/sandbox/configs/translation/translation_test.js index f2571c2cc..933d5fc68 100644 --- a/test/data/sandbox/configs/translation/translation_test.js +++ b/test/data/sandbox/configs/translation/translation_test.js @@ -1,17 +1,17 @@ -Caratteristica('DevTo'); +Funzionalità('DevTo') Prima(() => { - console.log('Before'); -}); + console.log('Before') +}) -lo_scenario('Simple translation test', () => { - console.log('Simple test'); -}); +Esempio('Simple translation test', () => { + console.log('Simple test') +}) Scenario('Simple translation test 2', () => { - console.log('Simple test 2'); -}); + console.log('Simple test 2') +}) Dopo(() => { - console.log('After'); -}); + console.log('After') +}) diff --git a/test/data/sandbox/i18n/codecept.bdd.nl.js b/test/data/sandbox/i18n/codecept.bdd.nl.js new file mode 100644 index 000000000..cd2f475bf --- /dev/null +++ b/test/data/sandbox/i18n/codecept.bdd.nl.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.nl.feature', + steps: ['./features/step_definitions/my_steps.nl.js'], + }, + include: {}, + bootstrap: false, + mocha: {}, + name: 'sandbox', + translation: 'nl-NL', +} diff --git a/test/data/sandbox/i18n/features/examples.nl.feature b/test/data/sandbox/i18n/features/examples.nl.feature new file mode 100644 index 000000000..84bf33ded --- /dev/null +++ b/test/data/sandbox/i18n/features/examples.nl.feature @@ -0,0 +1,16 @@ +#language: nl +Functionaliteit: Checkout proces + Om producten te kopen + Als klant + Moet ik in staat zijn om meerdere producten te kopen + + @i18n + Abstract Scenario: korting bestellen + Gegeven ik heb een product met een prijs van $ in mijn winkelwagen + En de korting voor bestellingen van meer dan $20 is 10 % + Wanneer ik naar de kassa ga + Dan zou ik de totaalprijs van "" $ moeten zien + + Voorbeelden: + | price | total | + | 10 | 10.0 | diff --git a/test/data/sandbox/i18n/features/step_definitions/my_steps.nl.js b/test/data/sandbox/i18n/features/step_definitions/my_steps.nl.js new file mode 100644 index 000000000..52537f762 --- /dev/null +++ b/test/data/sandbox/i18n/features/step_definitions/my_steps.nl.js @@ -0,0 +1,17 @@ +const I = actor() + +Given('ik heb een product met een prijs van {int}$ in mijn winkelwagen', price => { + I.addItem(parseInt(price, 10)) +}) + +Given('de korting voor bestellingen van meer dan ${int} is {int} %', (maxPrice, discount) => { + I.haveDiscountForPrice(maxPrice, discount) +}) + +When('ik naar de kassa ga', () => { + I.checkout() +}) + +Then('zou ik de totaalprijs van "{float}" $ moeten zien', price => { + I.seeSum(price) +}) diff --git a/test/runner/bdd_test.js b/test/runner/bdd_test.js index e959a31b5..ae0fb37fd 100644 --- a/test/runner/bdd_test.js +++ b/test/runner/bdd_test.js @@ -353,5 +353,25 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => { done() }) }) + + 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') + stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien') + stdout.should.include('On Gegeven: ik heb een product met een prijs van 10$ in mijn winkelwagen') + stdout.should.include('Ik add item 10') + stdout.should.include('On En: de korting voor bestellingen van meer dan $20 is 10 %') + stdout.should.include('Ik have discount for price 20, 10') + stdout.should.include('On Wanneer: ik naar de kassa ga') + stdout.should.include('Ik checkout') + stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien') + stdout.should.include('Ik see sum 10') + assert(!err) + done() + }) + }) }) }) diff --git a/test/unit/container_test.js b/test/unit/container_test.js index 2e8e422b0..5ff3a13c1 100644 --- a/test/unit/container_test.js +++ b/test/unit/container_test.js @@ -46,7 +46,7 @@ describe('Container', () => { expect(container.translation()).to.be.instanceOf(Translation) expect(container.translation().loaded).to.be.true expect(container.translation().I).to.eql('io') - expect(container.translation().value('contexts').Feature).to.eql('Caratteristica') + expect(container.translation().value('contexts').Feature).to.eql('Funzionalità') }) it('should create French translation', () => { diff --git a/translations/de-DE.js b/translations/de-DE.js index 7a84c985d..d1767d068 100644 --- a/translations/de-DE.js +++ b/translations/de-DE.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'de' + module.exports = { I: 'Ich', contexts: { - Feature: 'Funktionalität', - Scenario: 'Szenario', - ScenarioOutline: 'Szenariogrundriss', + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: 'befinde_mich_außerhalb_der_angular_app', diff --git a/translations/fr-FR.js b/translations/fr-FR.js index de67a063f..ba109ee59 100644 --- a/translations/fr-FR.js +++ b/translations/fr-FR.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'fr' + module.exports = { I: 'Je', contexts: { - Feature: 'Fonctionnalité', - Scenario: 'Scénario', - ScenarioOutline: 'Plan du scénario', + ...gherkinTranslations(langCode), Before: 'Avant', After: 'Après', BeforeSuite: 'AvantLaSuite', diff --git a/translations/index.js b/translations/index.js index 7767e717b..6e357e549 100644 --- a/translations/index.js +++ b/translations/index.js @@ -7,3 +7,4 @@ exports['pt-BR'] = require('./pt-BR') exports['ru-RU'] = require('./ru-RU') exports['zh-CN'] = require('./zh-CN') exports['zh-TW'] = require('./zh-TW') +exports['nl-NL'] = require('./nl-NL') diff --git a/translations/it-IT.js b/translations/it-IT.js index 2dd161467..b79b973ba 100644 --- a/translations/it-IT.js +++ b/translations/it-IT.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'it' + module.exports = { I: 'io', contexts: { - Feature: 'Caratteristica', - Scenario: 'lo_scenario', - ScenarioOutline: 'Schema dello scenario', + ...gherkinTranslations(langCode), Before: 'Prima', After: 'Dopo', BeforeSuite: 'Prima_della_suite', diff --git a/translations/ja-JP.js b/translations/ja-JP.js index acbcfca13..b749070f5 100644 --- a/translations/ja-JP.js +++ b/translations/ja-JP.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'ja' + module.exports = { I: '私は', contexts: { - Feature: 'フィーチャ', - Scenario: 'シナリオ', - ScenarioOutline: 'シナリオアウトライン', + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: 'Angularの外に出る', diff --git a/translations/nl-NL.js b/translations/nl-NL.js new file mode 100644 index 000000000..b336508c2 --- /dev/null +++ b/translations/nl-NL.js @@ -0,0 +1,76 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'nl' + +module.exports = { + I: 'Ik', + contexts: { + ...gherkinTranslations(langCode), + }, + actions: { + amOutsideAngularApp: 'ben_buiten_angular_app', + amInsideAngularApp: 'ben_binnen_angular_app', + waitForElement: 'wacht_op_element', + waitForClickable: 'wacht_tot_klikbaar', + waitForVisible: 'wacht_tot_zichtbaar', + waitForEnabled: 'wacht_tot_ingeschakeld', + waitForInvisible: 'wacht_tot_onzichtbaar', + waitInUrl: 'wacht_in_url', + waitForText: 'wacht_op_tekst', + moveTo: 'beweeg_de_cursor_naar', + refresh: 'vernieuw_pagina', + refreshPage: 'vernieuw_pagina', + haveModule: 'heb_module', + resetModule: 'reset_module', + amOnPage: 'ben_op_pagina', + click: 'klik', + doubleClick: 'dubbelklik', + see: 'zie', + dontSee: 'zie_niet', + selectOption: 'selecteer_optie', + fillField: 'vul_veld_in', + pressKey: 'druk_op_toets', + triggerMouseEvent: 'trigger_een_muis_event', + attachFile: 'voeg_bestand_toe', + seeInField: 'zie_in_veld', + dontSeeInField: 'zie_niet_in_veld', + appendField: 'voeg_toe_aan_veld', + checkOption: 'vink_optie_aan', + seeCheckboxIsChecked: 'zie_dat_checkbox_aangevinkt_is', + dontSeeCheckboxIsChecked: 'zie_niet_dat_checkbox_aangevinkt_is', + grabTextFrom: 'pak_tekst_van', + grabValueFrom: 'pak_waarde_van', + grabAttributeFrom: 'pak_attribuut_van', + seeInTitle: 'zie_in_titel', + dontSeeInTitle: 'zie_niet_in_titel', + grabTitle: 'pak_titel', + seeElement: 'zie_element', + dontSeeElement: 'zie_element_niet', + seeInSource: 'zie_in_broncode', + dontSeeInSource: 'zie_niet_in_broncode', + executeScript: 'voer_script_uit', + executeAsyncScript: 'voer_asynchroon_script_uit', + seeInCurrentUrl: 'zie_in_huidige_url', + dontSeeInCurrentUrl: 'zie_niet_in_huidige_url', + seeCurrentUrlEquals: 'zie_dat_url_gelijk_is', + dontSeeCurrentUrlEquals: 'zie_dat_url_niet_gelijk_is', + saveScreenshot: 'sla_screenshot_op', + setCookie: 'stel_cookie_in', + clearCookie: 'verwijder_cookie', + seeCookie: 'zie_cookie', + dontSeeCookie: 'zie_cookie_niet', + grabCookie: 'pak_cookie', + resizeWindow: 'verander_venstergrootte', + wait: 'wacht', + haveHeader: 'gebruik_http_header', + clearField: 'wis_veld', + dontSeeElementInDOM: 'zie_element_niet_in_DOM', + moveCursorTo: 'beweeg_de_cursor_naar', + scrollTo: 'scroll_naar', + sendGetRequest: 'doe_een_get_verzoek', + sendPutRequest: 'doe_een_put_verzoek', + sendDeleteRequest: 'doe_een_delete_verzoek', + sendDeleteRequestWithPayload: 'doe_een_delete_verzoek_met_payload', + sendPostRequest: 'doe_een_post_verzoek', + switchTo: 'wissel_naar_iframe', + }, +} diff --git a/translations/pl-PL.js b/translations/pl-PL.js index 4e3c21813..467e73594 100644 --- a/translations/pl-PL.js +++ b/translations/pl-PL.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'pl' + module.exports = { I: 'Ja', contexts: { - Feature: 'Funkcja', - Scenario: 'Scenariusz', - ScenarioOutline: 'Szablon scenariusza', + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: 'jestem_poza_aplikacją_angular', diff --git a/translations/pt-BR.js b/translations/pt-BR.js index 20b783994..9ac8ea674 100644 --- a/translations/pt-BR.js +++ b/translations/pt-BR.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'pt' + module.exports = { I: 'Eu', contexts: { - Feature: 'Funcionalidade', - Scenario: 'Cenário', - ScenarioOutline: 'Esquema do Cenário', + ...gherkinTranslations(langCode), Before: 'Antes', After: 'Depois', BeforeSuite: 'AntesDaSuite', diff --git a/translations/ru-RU.js b/translations/ru-RU.js index 21de4f9db..dd7892cbb 100644 --- a/translations/ru-RU.js +++ b/translations/ru-RU.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'ru' + module.exports = { I: 'Я', contexts: { - Feature: 'Цель', - Scenario: 'Сценарий', - ScenarioOutline: 'Структура сценария', + ...gherkinTranslations(langCode), Before: 'Начало', After: 'Конец', BeforeSuite: 'Перед_всем', diff --git a/translations/utils.js b/translations/utils.js new file mode 100644 index 000000000..45d42dba8 --- /dev/null +++ b/translations/utils.js @@ -0,0 +1,9 @@ +module.exports.gherkinTranslations = function (langCode) { + const gherkinLanguages = require('@cucumber/gherkin/src/gherkin-languages.json') + const { feature, scenario, scenarioOutline } = gherkinLanguages[langCode] + return { + Feature: feature[0], + Scenario: scenario[0], + ScenarioOutline: scenarioOutline[0], + } +} diff --git a/translations/zh-CN.js b/translations/zh-CN.js index f2a4ae1af..fe6aa40e1 100644 --- a/translations/zh-CN.js +++ b/translations/zh-CN.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'zh-CN' + module.exports = { I: '我', contexts: { - Feature: '功能', - Scenario: '场景', - ScenarioOutline: '场景大纲', + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: '在Angular应用外', diff --git a/translations/zh-TW.js b/translations/zh-TW.js index 908dcb38f..a8233211d 100644 --- a/translations/zh-TW.js +++ b/translations/zh-TW.js @@ -1,9 +1,10 @@ +const { gherkinTranslations } = require('./utils') +const langCode = 'zh-TW' + module.exports = { I: '我', contexts: { - Feature: '功能', - Scenario: '場景', - ScenarioOutline: '場景大綱', + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: '在Angular應用外',