Skip to content

Commit 236dc72

Browse files
authored
fix: allow gherkin keywords as supported by cucumber (#4784)
1 parent bc79dfe commit 236dc72

File tree

19 files changed

+206
-39
lines changed

19 files changed

+206
-39
lines changed

lib/mocha/gherkin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module.exports = (text, file) => {
107107
)
108108
continue
109109
}
110-
if (child.scenario && (currentLanguage ? child.scenario.keyword === currentLanguage.contexts.ScenarioOutline : child.scenario.keyword === 'Scenario Outline')) {
110+
if (child.scenario && (currentLanguage ? currentLanguage.contexts.ScenarioOutline.includes(child.scenario.keyword) : child.scenario.keyword === 'Scenario Outline')) {
111111
for (const examples of child.scenario.examples) {
112112
const fields = examples.tableHeader.cells.map(c => c.value)
113113
for (const example of examples.tableBody) {
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
Caratteristica('DevTo');
1+
Funzionalità('DevTo')
22

33
Prima(() => {
4-
console.log('Before');
5-
});
4+
console.log('Before')
5+
})
66

7-
lo_scenario('Simple translation test', () => {
8-
console.log('Simple test');
9-
});
7+
Esempio('Simple translation test', () => {
8+
console.log('Simple test')
9+
})
1010

1111
Scenario('Simple translation test 2', () => {
12-
console.log('Simple test 2');
13-
});
12+
console.log('Simple test 2')
13+
})
1414

1515
Dopo(() => {
16-
console.log('After');
17-
});
16+
console.log('After')
17+
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
exports.config = {
2+
tests: './*_no_test.js',
3+
timeout: 10000,
4+
output: '../output',
5+
helpers: {
6+
BDD: {
7+
require: '../support/bdd_helper.js',
8+
},
9+
},
10+
gherkin: {
11+
features: './features/examples.nl.feature',
12+
steps: ['./features/step_definitions/my_steps.nl.js'],
13+
},
14+
include: {},
15+
bootstrap: false,
16+
mocha: {},
17+
name: 'sandbox',
18+
translation: 'nl-NL',
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#language: nl
2+
Functionaliteit: Checkout proces
3+
Om producten te kopen
4+
Als klant
5+
Moet ik in staat zijn om meerdere producten te kopen
6+
7+
@i18n
8+
Abstract Scenario: korting bestellen
9+
Gegeven ik heb een product met een prijs van <price>$ in mijn winkelwagen
10+
En de korting voor bestellingen van meer dan $20 is 10 %
11+
Wanneer ik naar de kassa ga
12+
Dan zou ik de totaalprijs van "<total>" $ moeten zien
13+
14+
Voorbeelden:
15+
| price | total |
16+
| 10 | 10.0 |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const I = actor()
2+
3+
Given('ik heb een product met een prijs van {int}$ in mijn winkelwagen', price => {
4+
I.addItem(parseInt(price, 10))
5+
})
6+
7+
Given('de korting voor bestellingen van meer dan ${int} is {int} %', (maxPrice, discount) => {
8+
I.haveDiscountForPrice(maxPrice, discount)
9+
})
10+
11+
When('ik naar de kassa ga', () => {
12+
I.checkout()
13+
})
14+
15+
Then('zou ik de totaalprijs van "{float}" $ moeten zien', price => {
16+
I.seeSum(price)
17+
})

test/runner/bdd_test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,5 +353,25 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => {
353353
done()
354354
})
355355
})
356+
357+
it('should run feature files in NL', done => {
358+
exec(config_run_config('codecept.bdd.nl.js') + ' --steps --grep "@i18n"', (err, stdout, stderr) => {
359+
console.log(stdout)
360+
stdout.should.include('On Gegeven: ik heb een product met een prijs van 10$ in mijn winkelwagen')
361+
stdout.should.include('On En: de korting voor bestellingen van meer dan $20 is 10 %')
362+
stdout.should.include('On Wanneer: ik naar de kassa ga')
363+
stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien')
364+
stdout.should.include('On Gegeven: ik heb een product met een prijs van 10$ in mijn winkelwagen')
365+
stdout.should.include('Ik add item 10')
366+
stdout.should.include('On En: de korting voor bestellingen van meer dan $20 is 10 %')
367+
stdout.should.include('Ik have discount for price 20, 10')
368+
stdout.should.include('On Wanneer: ik naar de kassa ga')
369+
stdout.should.include('Ik checkout')
370+
stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien')
371+
stdout.should.include('Ik see sum 10')
372+
assert(!err)
373+
done()
374+
})
375+
})
356376
})
357377
})

test/unit/container_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('Container', () => {
4646
expect(container.translation()).to.be.instanceOf(Translation)
4747
expect(container.translation().loaded).to.be.true
4848
expect(container.translation().I).to.eql('io')
49-
expect(container.translation().value('contexts').Feature).to.eql('Caratteristica')
49+
expect(container.translation().value('contexts').Feature).to.eql('Funzionalità')
5050
})
5151

5252
it('should create French translation', () => {

translations/de-DE.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
const { gherkinTranslations } = require('./utils')
2+
const langCode = 'de'
3+
14
module.exports = {
25
I: 'Ich',
36
contexts: {
4-
Feature: 'Funktionalität',
5-
Scenario: 'Szenario',
6-
ScenarioOutline: 'Szenariogrundriss',
7+
...gherkinTranslations(langCode),
78
},
89
actions: {
910
amOutsideAngularApp: 'befinde_mich_außerhalb_der_angular_app',

translations/fr-FR.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
const { gherkinTranslations } = require('./utils')
2+
const langCode = 'fr'
3+
14
module.exports = {
25
I: 'Je',
36
contexts: {
4-
Feature: 'Fonctionnalité',
5-
Scenario: 'Scénario',
6-
ScenarioOutline: 'Plan du scénario',
7+
...gherkinTranslations(langCode),
78
Before: 'Avant',
89
After: 'Après',
910
BeforeSuite: 'AvantLaSuite',

translations/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ exports['pt-BR'] = require('./pt-BR')
77
exports['ru-RU'] = require('./ru-RU')
88
exports['zh-CN'] = require('./zh-CN')
99
exports['zh-TW'] = require('./zh-TW')
10+
exports['nl-NL'] = require('./nl-NL')

0 commit comments

Comments
 (0)