-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/29/scenario outline expander (#30)
* created precompiler * increased coverage * Documentation created - ScenarioOutlineExpander
- Loading branch information
Showing
19 changed files
with
278 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const DefaultConfig = require('../DefaultConfig'); | ||
|
||
/** | ||
* @typedef {Object} ScenarioOutlineExpanderConfiguration | ||
* @property {string} ignoreTag | ||
*/ | ||
const DEFAULT_CONFIG = { | ||
ignoreTag: '@notExpand' | ||
}; | ||
/** | ||
* The ScenarioOutlineExpander precompiler is responsible | ||
* for converting ScenarioOutlines to single Scenarios using the | ||
* first column of the Example table. | ||
*/ | ||
class ScenarioOutlineExpander extends DefaultConfig { | ||
/** | ||
* @constructor | ||
* @param {ScenarioOutlineExpanderConfig|Object} config | ||
*/ | ||
constructor(config) { | ||
super(); | ||
this.config = Object.assign({}, DEFAULT_CONFIG, config || {}); | ||
} | ||
|
||
onScenarioOutline(outline) { | ||
if (!outline.tags.length || !outline.tags.some(tag => this.config.ignoreTag === tag.name)) { | ||
return outline.toScenario(); | ||
} | ||
outline.tags = outline.tags.filter(tag => tag.name !== this.config.ignoreTag) | ||
} | ||
} | ||
|
||
module.exports = ScenarioOutlineExpander; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# ScenarioOutlineExpander for Gherkin precompiler | ||
|
||
This precompiler is responsible for converting Scenario Outlines to single Scenarios as Cucumber would do and adds the first column as a tag. | ||
|
||
Example: | ||
```gherkin | ||
@tag1 | ||
Scenario Outline: Test language (<language>) | ||
Given I am on Home page <language> user | ||
When <language> language is choosen | ||
Then I should be on Home page | ||
And the title should be "<title>" | ||
@tag2 | ||
Examples: | ||
| language | title | | ||
| EN | Welcome | | ||
| FR | Bienvenue | | ||
``` | ||
It will be modified to: | ||
|
||
```gherkin | ||
@tag1 @tag2 @language(EN) | ||
Scenario: Test language (EN) | ||
Given I am on Home page EN user | ||
When EN language is choosen | ||
Then I should be on Home page | ||
And the title should be "Welcome" | ||
@tag1 @tag2 @language(FR) | ||
Scenario: Test language (FR) | ||
Given I am on Home page FR user | ||
When FR language is choosen | ||
Then I should be on Home page | ||
And the title should be "Bienvenue" | ||
``` | ||
|
||
## Usage | ||
|
||
The precompiler accepts the following configuration: | ||
|
||
| Option | type | Description |Default| | ||
|:------:|:----:|:------------|:-----:| | ||
|`ignoreTag`|`String`| Tag used to mark scenarios to be ignored during expanding Scenario Outlines |`@notExpand`| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.