Skip to content

Commit

Permalink
beforeAll/AfterAll timeouts (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph authored Aug 16, 2017
1 parent 44b2cb9 commit eef8746
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
63 changes: 63 additions & 0 deletions features/before_after_all_hook_timeouts.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Feature: before / after all hook timeouts

Background:
Given a file named "features/a.feature" with:
"""
Feature:
Scenario:
Given a passing step
"""
And a file named "features/step_definitions/steps.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Given}) => {
Given(/^a passing step$/, function() {});
})
"""

Scenario Outline: slow handler timeout
Given a file named "features/support/handlers.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({<TYPE>, setDefaultTimeout}) => {
setDefaultTimeout(500)
<TYPE>(function(callback) {
setTimeout(callback, 1000)
})
})
"""
When I run cucumber.js
Then it fails
And the error output contains the text snippets:
| a handler errored, process exiting |
| function timed out after 500 milliseconds |
| features/support/handlers.js:6 |

Examples:
| TYPE |
| BeforeAll |
| AfterAll |

Scenario Outline: slow handler can increase their timeout
Given a file named "features/supports/handlers.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({<TYPE>, setDefaultTimeout}) => {
setDefaultTimeout(500)
<TYPE>({timeout: 1500}, function(callback) {
setTimeout(callback, 1000)
})
})
"""
When I run cucumber.js
Then it passes

Examples:
| TYPE |
| BeforeAll |
| AfterAll |
3 changes: 2 additions & 1 deletion src/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default class Runtime {
fn: hookDefinition.code,
thisArg: null,
timeoutInMilliseconds:
hookDefinition.timeout || this.supportCodeLibrary.defaultTimeout
hookDefinition.options.timeout ||
this.supportCodeLibrary.defaultTimeout
})
if (error) {
const location = formatLocation(hookDefinition)
Expand Down

0 comments on commit eef8746

Please sign in to comment.