From fa5b1751897704ff72cb9c361c132a2cb03bfaae Mon Sep 17 00:00:00 2001 From: Kevin Kuszyk Date: Thu, 4 Jan 2018 17:28:18 +0000 Subject: [PATCH] [cucumber] Update the HookScenarioResult to match the v3 api (#22651) --- types/cucumber/cucumber-tests.ts | 8 +++--- types/cucumber/index.d.ts | 44 +++++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/types/cucumber/cucumber-tests.ts b/types/cucumber/cucumber-tests.ts index 4d20be0085..f2aed9aec4 100644 --- a/types/cucumber/cucumber-tests.ts +++ b/types/cucumber/cucumber-tests.ts @@ -24,17 +24,17 @@ function StepSample() { }); Before((scenarioResult: HookScenarioResult, callback: Callback) => { - console.log(scenarioResult.status === Status.FAILED); + console.log(scenarioResult.result.status === Status.FAILED); callback(); }); Before({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => { - console.log(scenarioResult.status === Status.FAILED); + console.log(scenarioResult.result.status === Status.FAILED); callback(); }); Before('@tag', (scenarioResult: HookScenarioResult, callback: Callback) => { - console.log(scenarioResult.status === Status.FAILED); + console.log(scenarioResult.result.status === Status.FAILED); callback(); }); @@ -54,7 +54,7 @@ function StepSample() { }); Around((scenarioResult: HookScenarioResult, runScenario: (error: string | null, callback?: () => void) => void) => { - if (scenarioResult.status === Status.FAILED) { + if (scenarioResult.result.status === Status.FAILED) { runScenario(null, () => { console.log('finish tasks'); }); diff --git a/types/cucumber/index.d.ts b/types/cucumber/index.d.ts index 4824269363..8c2ad7020e 100644 --- a/types/cucumber/index.d.ts +++ b/types/cucumber/index.d.ts @@ -50,11 +50,49 @@ export interface StepDefinitions { } export interface HookScenarioResult { + sourceLocation: SourceLocation; + result: ScenarioResult; + pickle: pickle.Pickle; +} + +export interface SourceLocation { + line: number; + url: string; +} + +export interface ScenarioResult { duration: number; - failureException: Error; - scenario: Scenario; status: Status; - stepsResults: any; +} + +export namespace pickle { + interface Pickle { + language: string; + locations: Location[]; + name: string; + steps: Step[]; + tags: string[]; + } + + interface Location { + column: number; + line: number; + } + + interface Step { + arguments: Argument[]; + locations: Location[]; + text: string; + } + + interface Argument { + rows: Cell[]; + } + + interface Cell { + location: Location; + value: string; + } } export type HookCode = (this: World, scenario: HookScenarioResult, callback?: CallbackStepDefinition) => void;