Closed alexwizp closed 5 years ago
Also would like to set different timeouts on hooks.
I looked at the cucumber-js-tsflow source code, and there are two options for getting the scenario name..
option 1:
` @before() public beforeScenario(): void {
let world: any = (<any>this)._worldObj;
let scenarioContext = world.__SCENARIO_CONTEXT;
let scenarioInfo = <ScenarioInfo> scenarioContext._scenarioInfo;
console.log(JSON.stringify(scenarioInfo));
}
`
alternatively I've just submitted a pull request https://github.com/timjroberts/cucumber-js-tsflow/pull/19 which sets ScenarioInfo/FeatureInfo
` @before() public beforeScenario(): void {
console.log(`Before Scenario Hook: "${this.scenarioInfo.scenarioTitle}"`);
this.scenarioInfo.tags.forEach(tag =>
{
console.log(`\tScenario tag: "${tag}"`);
});
`
Accessing this scenario info should be possible from given/when/then steps also.
Will review the PR in the next day or so.
@timjroberts
I want to use @before() hook for a particular scenario. But it doesn't allow me to do so. In my case, i have a cucumber step file defined for different scenarios, in which i want to perform some operations to be execute before execution of the actual steps for few scenario.
so, is it possible to execute some operation with @before() for specific scenarios? If yes then please give an example.
After generated html report using the Cucumber JVM plugin, I found that for hooks we see the following names:
What do you think about changing the signature for hooks to:
before(name:
string, tag?: string, timeout?:number)
If I understand correctly we just need to set name into stepBinding to see the normal report