Skip to content

Commit

Permalink
fix: scenario outline examples variable multiple times in single step
Browse files Browse the repository at this point in the history
Merge pull request #211 from nipunsaini/fix-scenario-outline-multiple-vars
  • Loading branch information
lgandecki authored Aug 22, 2019
2 parents 6ee3fed + 8483dec commit c321a17
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cypress/integration/ScenarioOutline.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ Feature: Being a plugin handling Scenario Outline
| first | second | result |
| 1 | 2 | 3 |
| 3 | 4 | 7 |
| 5 | 6 | 11 |
| 5 | 6 | 11 |

Scenario Outline: Multiple variables <here> and <here>
When I enter variable "<here>" and "<here>"
Then I verify that both variables have "<here>" as value

Examples:
| here |
| abc |
14 changes: 14 additions & 0 deletions cypress/support/step_definitions/scenario_outline_multiple_vars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global then, when */

let var1 = "var1";
let var2 = "var2";

when("I enter variable {string} and {string}", (v1, v2) => {
var1 = v1;
var2 = v2;
});

then("I verify that both variables have {string} as value", value => {
expect(value).to.equal(var1);
expect(value).to.equal(var2);
});
2 changes: 1 addition & 1 deletion lib/createTestFromScenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { generateCucumberJson } = require("./cukejson/generateCucumberJson");

const replaceParameterTags = (rowData, text) =>
Object.keys(rowData).reduce(
(value, key) => value.replace(`<${key}>`, rowData[key]),
(value, key) => value.replace(new RegExp(`<${key}>`, "g"), rowData[key]),
text
);

Expand Down
1 change: 1 addition & 0 deletions lib/resolveStepDefinition.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe("Scenario Outline", () => {
require("../cypress/support/step_definitions/scenario_outline_integer");
require("../cypress/support/step_definitions/scenario_outline_string");
require("../cypress/support/step_definitions/scenario_outline_data_table");
require("../cypress/support/step_definitions/scenario_outline_multiple_vars");
resolveFeatureFromFile("./cypress/integration/ScenarioOutline.feature");
});

Expand Down

0 comments on commit c321a17

Please sign in to comment.