mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Updated Cucumber type definition (#13637)
to use the new Cucumber Support Code Interface.
This commit is contained in:
parent
2b2bff7d4f
commit
7f09dc728a
@ -1,23 +1,25 @@
|
||||
import cucumber = require("cucumber");
|
||||
import * as cucumber from "cucumber";
|
||||
import * as assert from "power-assert";
|
||||
|
||||
function StepSample() {
|
||||
type Callback = cucumber.CallbackStepDefinition;
|
||||
type Table = cucumber.TableDefinition;
|
||||
type HookScenario = cucumber.HookScenario;
|
||||
type Hooks = cucumber.Hooks;
|
||||
var step = <cucumber.StepDefinitions>this;
|
||||
var hook = <cucumber.Hooks>this;
|
||||
|
||||
hook.Before(function(scenario, callback){
|
||||
hook.Before(function(scenario: HookScenario, callback: Callback){
|
||||
scenario.isFailed() && callback.pending();
|
||||
})
|
||||
});
|
||||
|
||||
hook.Around(function(scenario, runScenario) {
|
||||
hook.Around(function(scenario: HookScenario, runScenario: (error:string, callback?:Function)=>void) {
|
||||
scenario.isFailed() && runScenario(null, function(){
|
||||
console.log('finish tasks');
|
||||
});
|
||||
});
|
||||
|
||||
hook.registerHandler('AfterFeatures', function (event, callback) {
|
||||
hook.registerHandler('AfterFeatures', function (event:any, callback:Function) {
|
||||
callback();
|
||||
});
|
||||
|
||||
@ -76,5 +78,21 @@ function StepSample() {
|
||||
];
|
||||
assert.deepEqual(table.hashes(), expected)
|
||||
});
|
||||
|
||||
cucumber.defineSupportCode(function(step: cucumber.StepDefinitions){
|
||||
step.Given( /^a variable set to (\d+)$/, (x:string) => {
|
||||
console.log("the number is: " + x);
|
||||
} );
|
||||
});
|
||||
cucumber.defineSupportCode(function(step: Hooks){
|
||||
step.After((scenario: HookScenario, callback?: Callback) => {
|
||||
console.log("After");
|
||||
callback();
|
||||
} )
|
||||
});
|
||||
|
||||
let fns : cucumber.SupportCodeConsumer[] = cucumber.getSupportCodeFns()
|
||||
|
||||
cucumber.clearSupportCodeFns();
|
||||
}
|
||||
|
||||
|
||||
8
cucumber/index.d.ts
vendored
8
cucumber/index.d.ts
vendored
@ -71,4 +71,12 @@ declare namespace cucumber {
|
||||
setDefaultTimeout(time:number): void;
|
||||
registerHandler(handlerOption:string, code:(event:any, callback:CallbackStepDefinition) =>void): void;
|
||||
}
|
||||
|
||||
export interface SupportCodeConsumer {
|
||||
(stepDefinitions:StepDefinitions | Hooks):void;
|
||||
}
|
||||
|
||||
export function defineSupportCode(consumer:SupportCodeConsumer): void;
|
||||
export function getSupportCodeFns(): SupportCodeConsumer[];
|
||||
export function clearSupportCodeFns(): void;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user