jest-cucumber icon indicating copy to clipboard operation
jest-cucumber copied to clipboard

Using Scenario Outline title placeholder doesn't work with autoBindSteps

Open closetpriyesh opened this issue 5 years ago • 5 comments

@bencompton

Hi Ben, It works well when I remove the placeholder from Scenario Outline title. Adding the code I used for reference. Thanks!!

//login.feature
Feature: Login
    Scenario Outline: <element> test
        When user is on home page
        Then user verifies <element>

        Examples:

            | element |
            | button   |
            | input      |
//login.steps.js
const { loadFeatures, autoBindSteps } = require("jest-cucumber");
const { CommonSteps } = require("./common.steps");
const { LoginSteps } = require("./newLogin.steps");
const features = loadFeatures("/Users/techcloset/Desktop/JEST/login.feature");
autoBindSteps(features, [CommonSteps, LoginSteps]);
Error:   at Object.<anonymous>.exports.checkThatFeatureFileAndStepDefinitionsHaveSameScenarios (node_modules/jest-cucumber/src/validation/scenario-validation.ts:111:15)
      at Suite.<anonymous> (node_modules/jest-cucumber/src/feature-definition-creation.ts:291:9)
      at Object.defineFeature (node_modules/jest-cucumber/src/feature-definition-creation.ts:286:5)
      at node_modules/jest-cucumber/src/automatic-step-binding.ts:30:9
          at Array.forEach (<anonymous>)
      at autoBindSteps (node_modules/jest-cucumber/src/automatic-step-binding.ts:29:14)
      at Object.<anonymous> (login.steps.js:5:1)

closetpriyesh avatar Oct 08 '20 08:10 closetpriyesh

Thank you, was able to reproduce!

bencompton avatar Oct 08 '20 15:10 bencompton

Fine👍 . No mention!

closetpriyesh avatar Oct 21 '20 06:10 closetpriyesh

I also encountered the issue, so I had a look at the source, did some debugging, and found a quick fix by sheer luck. Please see the PR, I'm not sure if it's the right way, but it does not break any tests, so I guess it's fine (I also added a test for this scenario).

Papooch avatar Sep 23 '21 15:09 Papooch

For the time being, if you require this functionality (like me) until the PR is accepted, you can install the dist branch (with built files) directly from github like so:

npm install Papooch/jest-cucumber#dist --save-dev

Papooch avatar Sep 24 '21 06:09 Papooch

Hi, @bencompton, would you mind reviewing the PR if it's alright? We've been using my fork in production since, so it would be great to have it merged.

Papooch avatar Feb 25 '22 10:02 Papooch