Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot save variables using nested steps and cy.fixture #1063

Closed
Javier-bat opened this issue Jul 28, 2023 · 1 comment
Closed

cannot save variables using nested steps and cy.fixture #1063

Javier-bat opened this issue Jul 28, 2023 · 1 comment

Comments

@Javier-bat
Copy link

Current behavior

When using nested steps the variables are not stored when using a cy.fixture. This doesn't happen if I don't use nested steps. I put 2 examples, the first fails the second passes successfully. behavior is different

Desired behavior

I expected the variables to be stored just like when nested steps are not used

Test code to reproduce

Feature: nesten steps

  Scenario: invoking step from another step
    Given a file named "cypress/e2e/a.feature" with:
      """
      Feature: a feature name

        Scenario: nested steps with cy.fixture 
          Given a nested step

      Scenario: no nested steps
          Given first nasted step
           And second nasted step
      """
    And a file named "cypress/fixtures/anyFixture.json" with:
    """
          {}
    """
    And a file named "cypress/e2e/a.js" with:
      """
      const { Given, Step } = require("@badeball/cypress-cucumber-preprocessor");
      Given("a nested step", function() {
        Step(this, "first nasted step");
        Step(this,"second nasted step")
      });
      Given("first nasted step", function() {
      cy.fixture("anyFixture").then((fixtureJson)=>{
                     this.randomText = "Hello world"
          })
      });
      Given("second nasted step", function() {
        expect(this.randomText).to.equal("Hello world");
      });

      """
    When I run cypress
    Then it passes

Versions

  • Cypress version: 12.17.1
  • Preprocessor version: 18.0.1
  • Node version: v18.16

Checklist

  • [x ] I've read the FAQ.
  • [x ] I've read instructions for logging issues.
  • [x ] I'm not using cypress-cucumber-preprocessor@4.3.1 (package name has changed and it is no longer the most recent version, see #689).
badeball added a commit that referenced this issue Jul 28, 2023
@badeball
Copy link
Owner

Hi @Javier-bat, thanks for reporting the issue and putting together an example for me. I've fixed and released this with v18.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants