From f5e4a39cb6abc57450413ac0643ac01448f293b4 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 3 Jan 2018 09:35:31 +0100 Subject: [PATCH] cucumber: add status enum (#22635) --- types/cucumber/cucumber-tests.ts | 9 +++++---- types/cucumber/index.d.ts | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/types/cucumber/cucumber-tests.ts b/types/cucumber/cucumber-tests.ts index 4447e5a7fe..a56d0514cd 100644 --- a/types/cucumber/cucumber-tests.ts +++ b/types/cucumber/cucumber-tests.ts @@ -12,6 +12,7 @@ function StepSample() { type Callback = cucumber.CallbackStepDefinition; type Table = cucumber.TableDefinition; type HookScenarioResult = cucumber.HookScenarioResult; + const Status = cucumber.Status; cucumber.defineSupportCode(({setWorldConstructor, defineParameterType, After, AfterAll, Around, Before, BeforeAll, registerHandler, Given, When, Then}) => { setWorldConstructor(function({attach, parameters}) { @@ -23,17 +24,17 @@ function StepSample() { }); Before((scenarioResult: HookScenarioResult, callback: Callback) => { - console.log(scenarioResult.status === "failed"); + console.log(scenarioResult.status === Status.FAILED); callback(); }); Before({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => { - console.log(scenarioResult.status === "failed"); + console.log(scenarioResult.status === Status.FAILED); callback(); }); Before('@tag', (scenarioResult: HookScenarioResult, callback: Callback) => { - console.log(scenarioResult.status === "failed"); + console.log(scenarioResult.status === Status.FAILED); callback(); }); @@ -53,7 +54,7 @@ function StepSample() { }); Around((scenarioResult: HookScenarioResult, runScenario: (error: string | null, callback?: () => void) => void) => { - if (scenarioResult.status === "failed") { + if (scenarioResult.status === Status.FAILED) { runScenario(null, () => { console.log('finish tasks'); }); diff --git a/types/cucumber/index.d.ts b/types/cucumber/index.d.ts index 56d094210d..d5683c385f 100644 --- a/types/cucumber/index.d.ts +++ b/types/cucumber/index.d.ts @@ -4,8 +4,18 @@ // Jan Molak // Isaiah Soung // BendingBender +// ErikSchierboom // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 + +export enum Status { + AMBIGUOUS = "ambiguous", + FAILED = "failed", + PASSED = "passed", + PENDING = "pending", + SKIPPED = "skipped", + UNDEFINED = "undefined" +} export interface World { [key: string]: any; @@ -43,7 +53,7 @@ export interface HookScenarioResult { duration: number; failureException: Error; scenario: Scenario; - status: string; + status: Status; stepsResults: any; } @@ -142,7 +152,7 @@ export namespace events { duration: any; failureException: Error; scenario: Scenario; - status: string; + status: Status; stepResults: any[]; } @@ -164,7 +174,7 @@ export namespace events { failureException: Error; step: Step; stepDefinition: StepDefinition; - status: string; + status: Status; } }