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

  1. Before/After Hooks inside the steps definitions file with same order they were defined
  2. 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)

Most upvoted comments

I don’t see anything about specifying order in cucumber-js in the link you mention, @NachoVazquez. What are you referring to?

It is about down in the before section.

image

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.