cypress-cucumber-preprocessor: Cant specify the order of cucumber Before/After hooks if they exist in the common and step definition file
Current behavior
With nonGlobalStepDefinitions is set to true Having Before/After hooks in the common file and another Before/After inside test it will be executed as following
- Before/After Hooks inside the steps definitions file with same order they were defined
- Before/After hooks inside the common file with same order they were defined
Default order is test hooks then common hooks, Im trying to achieve some common hooks that prepare the data then inside the test Before/After hooks can continue were common hooks stopped per test need
Desired behavior
Ability to specify the order of cucumber hooks
As example
Before({ tags: "@prepareData", order: 1 }, () => {
Without specifying the order execution will remain as default
Test code to reproduce
cucumberHooksTest.feature
@commonPrepareData @testPrepareData
Scenario: Test cucumber hooks order run
Given Test Given
cucumberHooksTestSteps.ts
Before({ tags: "@testPrepareData" }, () => { console.log("testHook"); }); Given("Test Given",() => {})
commonHooks.ts
Before({ tags: "@commonPrepareData" }, () => { console.log("common hook"); });
Output of above is testHook commonHook
Note we already implemented adding order for cucumber Before/After hooks if we agreed to use them will share PR for it
Versions
- Cypress version: 6.0.0
- Preprocessor version: 4.0.0
- Node version: 12.4.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (5 by maintainers)
It is about down in the before section.
You can specify the order on CucumberJS https://cucumber.io/docs/cucumber/api/#hooks
This would be helpful to have.
No. Given the existence in cucumber-jvm, I’d be open to adding it here as well. Contributions are welcome.