diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js index 8da0e542e..81d8de4e6 100644 --- a/lib/interfaces/bdd.js +++ b/lib/interfaces/bdd.js @@ -25,7 +25,8 @@ const parameterTypeRegistry = new ParameterTypeRegistry(); const matchStep = (step) => { for (const stepName in steps) { if (stepName.indexOf('/') === 0) { - const res = step.match(new RegExp(stepName.slice(1, -1))); + const regExpArr = stepName.match(new RegExp('^/(.*?)/([gimy]*)$')) || []; + const res = step.match(new RegExp(regExpArr[1], regExpArr[2])); if (res) { const fn = steps[stepName]; fn.params = res.slice(1); @@ -56,6 +57,7 @@ module.exports = { Given: addStep, When: addStep, Then: addStep, + And: addStep, matchStep, getSteps, clearSteps, diff --git a/test/unit/bdd_test.js b/test/unit/bdd_test.js index 9a4b738de..d20f7b307 100644 --- a/test/unit/bdd_test.js +++ b/test/unit/bdd_test.js @@ -3,6 +3,7 @@ const { Parser } = require('gherkin'); const { Given, When, + And, Then, matchStep, clearSteps, @@ -64,10 +65,12 @@ describe('BDD', () => { it('should load step definitions', () => { Given('I am a bird', () => 1); When('I fly over ocean', () => 2); - Then(/I see (.*?)/, () => 3); + And(/^I fly over land$/i, () => 3); + Then(/I see (.*?)/, () => 4); expect(1).is.equal(matchStep('I am a bird')()); - expect(3).is.equal(matchStep('I see ocean')()); - expect(3).is.equal(matchStep('I see world')()); + expect(3).is.equal(matchStep('I Fly oVer Land')()); + expect(4).is.equal(matchStep('I see ocean')()); + expect(4).is.equal(matchStep('I see world')()); }); it('should contain tags', async () => {