Contents

before / after all hook timeouts

Background:

  • Given a file named "features/a.feature" with:
    gherkin
    Feature:
      Scenario:
        Given a passing step
  • And a file named "features/step_definitions/steps.js" with:
    ruby
    const {Given} = require('@cucumber/cucumber')
    
    Given(/^a passing step$/, function() {});

Scenario Outline: slow handler timeout

  • Given a file named "features/support/handlers.js" with:
    ruby
    const {<TYPE>, setDefaultTimeout} = require('@cucumber/cucumber')
    
    setDefaultTimeout(500)
    
    <TYPE>(function(callback) {
      setTimeout(callback, 1000)
    })
  • When I run cucumber-js
  • Then it fails
  • And the output contains the text:
    text
    1 hook (1 failed)
  • And the output contains the text:
    text
    function timed out, ensure the callback is executed within 500 milliseconds
  • And the output contains the text:
    text
    features/support/handlers.js:5

Examples:

TYPE
BeforeAll
AfterAll

Scenario Outline: slow handlers can increase their timeout

  • Given a file named "features/supports/handlers.js" with:
    ruby
    const {<TYPE>, setDefaultTimeout} = require('@cucumber/cucumber')
    
    setDefaultTimeout(500)
    
    <TYPE>({timeout: 1500}, function(callback) {
      setTimeout(callback, 1000)
    })
  • When I run cucumber-js
  • Then it passes

Examples:

TYPE
BeforeAll
AfterAll

Source: features/before_after_all_hook_timeouts.feature at commit 3ac6ecda, Cucumber Js (MIT license).