Cucumber-js: Empty strings params trip parsing in v6+

Created on 9 Oct 2019  Â·  11Comments  Â·  Source: cucumber/cucumber-js

Repro in: https://github.com/jbblanchet/cucumber-error

Test Given string "" equals "" will crash with

.F

Failures:

1) Scenario: Empty String # features/strings.feature:6
   ✖ Given string "" equals "" # features/support/steps.js:4
       TypeError: Cannot read property 'replace' of undefined
           at World.<anonymous> (/home/jbb/temp/cucumber-error/node_modules/cucumber-expressions/dist/src/ParameterTypeRegistry.js:27:141)
           at ParameterType.transform (/home/jbb/temp/cucumber-error/node_modules/cucumber-expressions/dist/src/ParameterType.js:63:33)
           at Argument.getValue (/home/jbb/temp/cucumber-error/node_modules/cucumber-expressions/dist/src/Argument.js:29:35)

because the string is undefined, and not empty, and the code attempts to do undefined.replace. Not sure if the fix would be to parse the empty string as an empty string, to to check for undefined in cucumber-expressions. Also not sure this was the right repo to open the issue.

All 11 comments

Interesting. Yep appears to be a bug. Will open an issue on cucumber-expressions (which lives in the cucumber monorepo)

@charlierudolph thanks for filing the bug there, I wasn't sure where it needed to be :smile:

I noticed a fix was merged 9 days ago in the monorepo. Is there any plans to do a release? This is blocking our migration to v6.

Thanks

6.0.3 was released, but it still gives me the same error

@Gerb81 it will be included in the next release of cucumber-expressions: https://github.com/cucumber/cucumber/blob/master/cucumber-expressions/CHANGELOG.md

@Gerb81 I just released cucumber-expressions 8.0.2. Can you try again? (If you have a yarn.lock or package-lock.json pinning to 8.0.1 you'll have to yarn upgrade --latest or similar).

@aslakhellesoy it worked, thank you!

@jbblanchet Can you check if this issue can get closed?

@FibreFoX sure. Didn't know you were waiting for me. I'll upgrade cucumber this morning and will let you know.

@FibreFoX It works with an caveat. If I ensure my cucumber-expressions is ^8.1.0 it'll work, but [email protected] is still only asking for cucumber-expressions ^8.0.1, which still has the bug. So with lockfiles, it's possible to still get the problem. For this issue to be truly closed, I think a 6.0.4 release that asks for the patched dependency would be preferable.

Opened a PR to explicitly update the dependency here.

v6.0.4 released with the updated dependency

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edwinwright picture edwinwright  Â·  3Comments

hdorgeval picture hdorgeval  Â·  3Comments

protoman92 picture protoman92  Â·  3Comments

bmsoko picture bmsoko  Â·  7Comments

zanona picture zanona  Â·  4Comments