Added StepDefinitionOptions as a 1st arg to Before/After

Cucumber supports the use of a timeout as the 1st argument in the
Before/After hooks.
This commit is contained in:
isoung
2017-03-15 19:00:04 -05:00
parent 9e1f287385
commit aa125716cd
2 changed files with 15 additions and 1 deletions
+9 -1
View File
@@ -3,7 +3,7 @@ import cucumber = require("cucumber");
function StepSample() {
type Callback = cucumber.CallbackStepDefinition;
type Table = cucumber.TableDefinition;
type Table = cucumber.TableDefinition;
type HookScenario = cucumber.HookScenario;
type Hooks = cucumber.Hooks;
var step = <cucumber.StepDefinitions>this;
@@ -19,6 +19,14 @@ function StepSample() {
scenario.isFailed() && callback.pending();
});
hook.Before({ timeout: 1000 }, function(scenario: HookScenario, callback: Callback) {
callback();
});
hook.After({ timeout: 1000 }, function(scenario: HookScenario, callback: Callback) {
callback();
});
hook.Around(function(scenario: HookScenario, runScenario: (error:string, callback?:Function)=>void) {
scenario.isFailed() && runScenario(null, function(){
console.log('finish tasks');
+6
View File
@@ -70,9 +70,15 @@ declare namespace cucumber {
typeName: string;
}
interface HookOptions{
timeout?: number;
}
export interface Hooks {
Before(code: HookCode): void;
Before(options: HookOptions, code: HookCode): void;
After(code: HookCode): void;
After(options: HookOptions, code: HookCode): void;
Around(code: AroundCode):void;
setDefaultTimeout(time:number): void;
setWorldConstructor(world: () => void): void;