You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On CucumberJS 2.2:
TL;DR - When working with RegExp steps, parameters with inner groups aren't processed by the matching parameter types.
Steps to reproduce (exact code provided below):
Define a step using regexp with a parameter that includes inner non-capturing groups.
Define a parameter type tracking this parameter.
The parameter type transform function doesn't execute.
Reproduce with the following scenarios (to be added to /features/parameter_types.feature):
Demonstrate the bug itself (will fail):
Scenario: transform regexp with groups
Given a file named "features/demo_steps.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a demo step
"""
Given a file named "features/step_definitions/my_steps.js" with:
"""
import assert from 'assert'
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Given}) => {
Given(/a (demo(?:nstration)?) step/, function(param) {
assert.equal(param, 'DEMO')
})
})
"""
Given a file named "features/support/transforms.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({defineParameterType}) => {
defineParameterType({
regexp: /demo(?:nstration)?/,
transformer: s => s.toUpperCase(),
typeName: 'param'
})
})
"""
When I run cucumber.js
Then the step "a demo step" has status "passed"
Demonstrate the bug doesn't occur without capture groups (will pass):
Scenario: transform without groups
Given a file named "features/demo_steps.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a demo step
"""
Given a file named "features/step_definitions/my_steps.js" with:
"""
import assert from 'assert'
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Given}) => {
Given(/a (demo|demonstration) step/, function(param) {
assert.equal(param, 'DEMO')
})
})
"""
Given a file named "features/support/transforms.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({defineParameterType}) => {
defineParameterType({
regexp: /demo|demonstration/,
transformer: s => s.toUpperCase(),
typeName: 'param'
})
})
"""
When I run cucumber.js
Then the step "a demo step" has status "passed"
Demonstrate the bug doesn't occur with cucumber expressions (will pass):
Scenario: transform expression with groups
Given a file named "features/demo_steps.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a demo step
"""
Given a file named "features/step_definitions/my_steps.js" with:
"""
import assert from 'assert'
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Given}) => {
Given('a {param} step', function(param) {
assert.equal(param, 'DEMO')
})
})
"""
Given a file named "features/support/transforms.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({defineParameterType}) => {
defineParameterType({
regexp: /demo(?:nstration)?/,
transformer: s => s.toUpperCase(),
typeName: 'param'
})
})
"""
When I run cucumber.js
Then the step "a demo step" has status "passed"
From @yaronassa on June 7, 2017 19:32
On CucumberJS 2.2:
TL;DR - When working with RegExp steps, parameters with inner groups aren't processed by the matching parameter types.
Steps to reproduce (exact code provided below):
The parameter type transform function doesn't execute.
Reproduce with the following scenarios (to be added to
/features/parameter_types.feature
):Demonstrate the bug itself (will fail):
Demonstrate the bug doesn't occur without capture groups (will pass):
Demonstrate the bug doesn't occur with cucumber expressions (will pass):
Copied from original issue: cucumber/cucumber-js#849
The text was updated successfully, but these errors were encountered: