Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Cucumber version in v8 #1853

Closed
jan-molak opened this issue Nov 30, 2021 · 4 comments
Closed

Expose Cucumber version in v8 #1853

jan-molak opened this issue Nov 30, 2021 · 4 comments
Labels
✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality

Comments

@jan-molak
Copy link
Member

jan-molak commented Nov 30, 2021

Is your feature request related to a problem? Please describe.

Serenity/JS currently supports Cucumber versions 1.x to 7.x and I'd like it to be able to support version 8.x as well.

In order to do that, Serenity/JS needs to know what version of Cucumber it's being used with.

At the moment, Serenity/JS figures out the version based on the version field present in Cucumber's package.json file.

However, in Cucumber 8 RC1 package.json is not listed in exports, so trying to require('@cucumber/cucumber/package.json') results in:

 Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports"

Describe the solution you'd like

It would be great if Cucumber 8 could either:

  • add package.json to its exports so that Serenity/JS could read the version from it
  • export a version const so that it could be imported by consumer frameworks (e.g. import { version } from '@cucumber/cucumber')

Describe alternatives you've considered

An alternative solution would be for Serenity/JS to check if @cucumber/cucumber module is present, and if it is and it's not possible to load its package.json => assume it's version 8.

It could work, but it smells of a an awful hack ;-)

Additional context
N/A

@jan-molak jan-molak changed the title Expose Cucumber version Expose Cucumber version in v8 Nov 30, 2021
@aurelien-reeves aurelien-reeves added the ⚡ enhancement Request for new functionality label Nov 30, 2021
@aurelien-reeves
Copy link
Contributor

Indeed, we should try to find a way before releasing final version of 8.0.0

Thanks for the report!

@aurelien-reeves aurelien-reeves added the ✅ accepted The core team has agreed that it is a good idea to fix this label Nov 30, 2021
@jan-molak
Copy link
Member Author

Thanks, give me a shout if you'd like me to try it again with any new RCs.

@aurelien-reeves
Copy link
Contributor

@jan-molak just pushed a PR: #1866

In your case, to make it work with previous version of cucumber, and incoming ones, you may consider relying on the CLI to retrieve the version of cucumber (executing cucumber-js --version). Pretty sure that would be the more reliable way when working with cucumber before and after v8

@jan-molak
Copy link
Member Author

Nice one, thanks @aurelien-reeves, #1866 looks great.
I'm invoking Cucumber.js programmatically rather than spawning a new process, so importing a version is preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants