Is it possible to get Scenario details (name, tags, etc.) if After method?
Hi, I'm using Cypress with cypress-cucumber-preprocessor and want to integrate it with TestRail. I was going to add test case id as tag to scenarios, but looks like test result object is not provided to After method (unlike Cucumber.js). Is there any way to handle this situation, thanks?
Workaround
Following code can be added to lib/createTestFromScenario.js in runTest() to get the current scenario detail
Cypress.env('currentScenario', scenario);
+1 on this request. I was able to try the workaround and it works, but don't want to modify it in node_modules.
BTW, this tool is awesome! Thank you!
Picking up on @amitguptagwl 's suggestion - the current scenario detail is already available during the time that the scenario is being run without needing to patch node_modules.
window.testState.currentScenario
Also, from within a cucumber After block the results of the steps executed during the scenario can be obtained from
window.testState.stepResults
It would be nice to make custom World overriding possible. Anyway for scenario results there is a cucumber way to obtain scenario results (works in Protractor, but unfortunately in this preprocessor). You could try adding it if possible:
Custom World class:
export class World {
constructor() {}
testFunction() {
console.log('From testFunction()');
}
}
setWorldConstructor(World); // imported directly from cucumber
After hook and getting the scenario results:
After(async function(this: World, scenario: HookScenarioResult) {
console.log(scenario.result);
console.log(this.testFunction);
});
Hi, I'm totally new to cypress and js, and trying to move our old cucumber-selenium(ruby) project to cypress-cucumber.
I'm looking for a way to get each scenario's tag and pass them as a variable, but I don't know how and where to call this file \lib\createTestsFromFeature.js
I tried to use it under step definition, but cypress throws out error
in "lib/createTestsFromFeature.js:7:41" ==> const featureTags = testState.feature.tags; Cannot read property 'tags' of undefined
I copied whole /lib folder to my project, I'm totally lost, can anyone help? thanks very very much!!
Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.
Read more about the transfer of ownership here.
The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.