<commit_before>Feature: Tagged Hooks
  As a developer running features
  I want the ability to control which scenarios my hooks run for
  Because not all my scenarios have the same setup and teardown

  Scenario: ability to specify tags for hooks
    Given a file named "features/a.feature" with:
      """
      Feature:
        Scenario:
          Then the value is 0

        @foo
        Scenario:
          Then the value is 1
      """
    And a file named "features/step_definitions/world.js" with:
      """
      const {setWorldConstructor} = require('cucumber')

      setWorldConstructor(function() {
        this.value = 0
      })
      """
    And a file named "features/step_definitions/my_steps.js" with:
      """
      const assert = require('assert')
      const {Then} = require('cucumber')

      Then(/^the value is (\d*)$/, function(number) {
        assert.equal(number, this.value)
      })
      """
    And a file named "features/step_definitions/my_tagged_hooks.js" with:
      """
      const {Before} = require('cucumber')

      Before({tags: '@foo'}, function() {
        this.value += 1
      })
      """
    When I run cucumber-js
    Then it passes<commit_msg>hooks: prove that tags cascade from feature when matching in hooks (#1285)<commit_after>Feature: Tagged Hooks
  As a developer running features
  I want the ability to control which scenarios my hooks run for
  Because not all my scenarios have the same setup and teardown

  Background:
    Given a file named "features/step_definitions/world.js" with:
      """
      const {setWorldConstructor} = require('cucumber')

      setWorldConstructor(function() {
        this.foo = false
        this.bar = false
      })
      """
    And a file named "features/step_definitions/my_steps.js" with:
      """
      const assert = require('assert')
      const {Then} = require('cucumber')

      Then('{word} is true', function(prop) {
        assert.equal(true, this[prop])
      })

      Then('{word} is false', function(prop) {
        assert.equal(false, this[prop])
      })
      """
    And a file named "features/step_definitions/my_tagged_hooks.js" with:
      """
      const {Before} = require('cucumber')

      Before({tags: '@foo'}, function() {
        this.foo = true
      })

      Before({tags: '@bar'}, function() {
        this.bar = true
      })
      """

  Scenario: hooks filtered by tags on scenario
    Given a file named "features/a.feature" with:
      """
      Feature:
        @foo
        Scenario:
          Then foo is true
          And bar is false
      """
    When I run cucumber-js
    Then it passes

  Scenario: tags cascade from feature to scenario
    Given a file named "features/a.feature" with:
      """
      @foo
      Feature:
        Scenario:
          Then foo is true
          And bar is false
      """
    When I run cucumber-js
    Then it passes
{'fraction_non_alphanumeric': 0.10479145122371596, 'fraction_numerical': 0.002757669769045157, 'mean_word_length': 2.196035242290749, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1528416', 'n_tokens_mistral': 841, 'n_tokens_neox': 813, 'n_words': 271}