question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for nested steps

See original GitHub issue

In eg. cucumber-ruby, one has the ability to invoke steps from step definitions, as shown here. It would be super cool to have this support in cypress-cucumber-preprocessor as well.

Right now, I’ve solved it using resolveAndRunStepDefinition, but I realize that this isn’t part of the official API.

Feature: some feature
  Scenario: some scenario
    When within "some section" I fill in "foo" for "bar"
const { When } = require("cypress-cucumber-preprocessor/steps");
const { resolveAndRunStepDefinition } = require("cypress-cucumber-preprocessor/lib/resolveStepDefinition");

When("within {string} {}", (section, subExpression) => {
  cy.contains("section", section).within(() => {
    resolveAndRunStepDefinition({
      keyword: "When",
      text: subExpression
    });
  });
});

When("I fill in {string} for {string}", (text, label) => {
  cy.get(`input[label='${label}']`)
    .type(text);
});

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
edmodo-CeciliaChencommented, Jan 29, 2021

In my case, we don’t contain the to-be-called-step in feature line, so I wrote a function using the workaround @badeball provided:

import cucumberStep from 'cypress-cucumber-preprocessor/lib/resolveStepDefinition';

function RunStep(step) {
    cy.log("Step: "+step);
    cucumberStep.resolveAndRunStepDefinition({
        keyword: "*",
        text: step
      });
}

then call it in step_definition file

import {RunStep} from '../util';

Then(/(.*): user send a chat with text "(.*)"/, (page_name, text) => {
    RunStep(page_name +': user clicks on "CHAT_BOX"');
    RunStep(page_name +': user input "' + text +  '" in "CHAT_BOX_INPUT"');
    RunStep(page_name +': user clicks on "SENT_BUTTON"');
});

it worked perfectly, thanks to this workaround.

1reaction
amitguptagwlcommented, Sep 26, 2019

@badeball reported to them

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for nested steps · Issue #170 - GitHub
In eg. cucumber-ruby , one has the ability to invoke steps from step definitions, as shown here. It would be super cool to...
Read more >
AWS Step Functions Adds Support for Nested Workflows
Step Functions lets you coordinate multiple AWS services in fully-managed workflows so you can build and update apps quickly.
Read more >
Nested Steps - Defining steps - Cucumber - Relish
Nested Steps · Use #steps to call several steps at once · Use #step to call a single step · Use #steps to...
Read more >
Expanding nested steps on execution - Google Groups
I really dig Cucumber's support for building complex steps out of simpler ones, but sometimes I wish there was an option to "expand"...
Read more >
nested-steps - npm
Start using nested-steps in your project by running `npm i nested-steps`. There are no other projects in the npm registry using nested-steps.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found