Search code examples
javascriptcucumbercucumberjs

How to fix "TypeError: this.parameterTypes is not a function" in cucumber-js?


I am trying to use Cucumber.js but for some reason the snippet generation is broken. I am not sure if my setup is wrong or if there's a bug in cucumber-js itself.

I setup a simple test project https://github.com/cwansart/cucumber-js-test and ran npx cucumber-js which throws the following errors:

TypeError: this.parameterTypes is not a function
    at CucumberExpressionGenerator.createParameterTypeMatchers (/home/runner/work/cucumber-js-test/cucumber-js-test/node_modules/@cucumber/cucumber-expressions/dist/src/CucumberExpressionGenerator.js:110:41)
    at CucumberExpressionGenerator.generateExpressions (/home/runner/work/cucumber-js-test/cucumber-js-test/node_modules/@cucumber/cucumber-expressions/dist/src/CucumberExpressionGenerator.js:27:42)
Error: Process completed with exit code 1.

See: https://github.com/cwansart/cucumber-js-test/runs/1854253039

I tried to find the issue in the cucumber code but have not been successful so far.

The tests work then I add the then block in the features/support/steps.js again.

How to fix this?


Solution

  • Nothing wrong at all with what you're doing (thanks for the test repo btw, that helped), it's an issue with a new version of a dependency.

    Here's the GitHub issue: https://github.com/cucumber/cucumber-js/issues/1571

    There'll be a patch version of cucumber-js coming soon to address this but in the meantime if you override the version of @cucumber/cucumber-expressions in your project to 11.0.0 (so it doesn't pick up 11.0.1) that should work around it.

    Update: A patch has been released to revert the issue:

    we've just released cucumber-expressions version 11.0.2 which fixes a regression from 11.0.1. If you npm update [in your project] the problem should go away.