Book Image

Learning Behavior-driven development with Javascript

Book Image

Learning Behavior-driven development with Javascript

Overview of this book

Table of Contents (17 chapters)
Learning Behavior-driven Development with JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Useful Cucumber.js features


There are some features in Cucumber.js that can be handy in certain situations. Let's see what they are.

Tagging features and scenarios

You can tag features, scenarios, and Examples: sections to selectively execute only tagged parts of your specification.

You can create a tag using the @ character as follows:

@ready
Feature: Some feature

  @simple
  Scenario: scenario 1
    # Skipped for brevity
  @errorcase
  Scenario: scenario 2
    # Skipped for brevity
  @important @regression
  Scenario Outline: scenario 3
    # Skipped for brevity

  Examples:
    | placeholder 1 | placeholder 2 |
    | example 1.1   | example 1.2   |
    | example 2.1   | example 2.2   |

 @complicated
    Examples:
    | placeholder 1 | placeholder 2 |
    | example 3     | example 2     |

You can simply put a space-separated list of tags in any section of the Gherkin code. If you add tags at the feature level, all its scenarios will inherit it.

To run the scenarios selectively, you can use...