From 52f0247b134e14c318f478d235d2f5ca1746a984 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Fri, 11 Aug 2017 08:44:55 -0700 Subject: [PATCH 1/2] update --- features/before_after_all_timeouts.feature | 63 ++++++++++++++++++++++ src/runtime/index.js | 3 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 features/before_after_all_timeouts.feature diff --git a/features/before_after_all_timeouts.feature b/features/before_after_all_timeouts.feature new file mode 100644 index 000000000..e8fd2c709 --- /dev/null +++ b/features/before_after_all_timeouts.feature @@ -0,0 +1,63 @@ +Feature: registerHandler 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(({, setDefaultTimeout}) => { + setDefaultTimeout(500) + + (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(({, setDefaultTimeout}) => { + setDefaultTimeout(500) + + ({timeout: 1500}, function(callback) { + setTimeout(callback, 1000) + }) + }) + """ + When I run cucumber.js + Then it passes + + Examples: + | TYPE | + | BeforeAll | + | AfterAll | diff --git a/src/runtime/index.js b/src/runtime/index.js index b154947e8..82b96e86e 100644 --- a/src/runtime/index.js +++ b/src/runtime/index.js @@ -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) From 5ba8af1c7b4b1b4b78c9fc9feb03b9fca3ace823 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Fri, 11 Aug 2017 08:46:04 -0700 Subject: [PATCH 2/2] update --- ..._timeouts.feature => before_after_all_hook_timeouts.feature} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename features/{before_after_all_timeouts.feature => before_after_all_hook_timeouts.feature} (97%) diff --git a/features/before_after_all_timeouts.feature b/features/before_after_all_hook_timeouts.feature similarity index 97% rename from features/before_after_all_timeouts.feature rename to features/before_after_all_hook_timeouts.feature index e8fd2c709..b09e14bed 100644 --- a/features/before_after_all_timeouts.feature +++ b/features/before_after_all_hook_timeouts.feature @@ -1,4 +1,4 @@ -Feature: registerHandler timeouts +Feature: before / after all hook timeouts Background: Given a file named "features/a.feature" with: