Skip to content

Commit

Permalink
cli: repeatable tags option (#940)
Browse files Browse the repository at this point in the history
resolves #939
  • Loading branch information
kozhevnikov authored and charlierudolph committed Oct 4, 2017
1 parent 81aeaed commit fb9e8fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ In order to store and reuse commonly used CLI options, you can add a `cucumber.j

## Tags

Use `--tags <EXPRESSION>` to run specific features or scenarios.
Use `--tags <EXPRESSION>` to run specific features or scenarios. This option is repeatable and the expressions will be merged with `and` operator.
`<EXPRESSION>` is a [cucumber tag expression](https://docs.cucumber.io/tag-expressions/).

## Transpilers
Expand Down
7 changes: 7 additions & 0 deletions features/target_specific_scenarios_by_tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ Feature: Target specific scenarios
Then it fails
And it runs the scenario "first scenario"

Scenario: merge multiple tag expressions
When I run cucumber.js with `--tags @b --tags "not @c"`
Then it fails
And it runs the scenarios:
| NAME |
| second scenario - Z |

Scenario: run a single scenario outline
When I run cucumber.js with `--tags @b`
Then it fails
Expand Down
7 changes: 6 additions & 1 deletion src/cli/argv_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default class ArgvParser {
}
}

static mergeTags(val, memo) {
return memo === '' ? `(${val})` : `${memo} and (${val})`
}

static validateLanguage(val) {
if (!_.includes(_.keys(Gherkin.DIALECTS), val)) {
throw new Error('Unsupported ISO 639-1: ' + val)
Expand Down Expand Up @@ -89,7 +93,8 @@ export default class ArgvParser {
)
.option(
'-t, --tags <EXPRESSION>',
'only execute the features or scenarios with tags matching the expression',
'only execute the features or scenarios with tags matching the expression (repeatable)',
ArgvParser.mergeTags,
''
)
.option(
Expand Down

0 comments on commit fb9e8fc

Please sign in to comment.