Merge pull request #15196 from isoung/master

cucumber: Added HookOptions as a 1st arg to Before/After hooks
This commit is contained in:
Paul van Brenk
2017-03-21 14:57:52 -07:00
committed by GitHub
2 changed files with 16 additions and 2 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');
+7 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for cucumber-js
// Project: https://github.com/cucumber/cucumber-js
// Definitions by: Abraão Alves <https://github.com/abraaoalves>, Jan Molak <https://github.com/jan-molak>
// Definitions by: Abraão Alves <https://github.com/abraaoalves>, Jan Molak <https://github.com/jan-molak>, Isaiah Soung <https://github.com/isoung>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = cucumber;
@@ -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;