Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beforeAll/AfterAll timeouts #899

Merged
merged 2 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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