diff --git a/CHANGELOG.md b/CHANGELOG.md index be7e60b28..71edc581c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO ## [Unreleased] ### Fixed +- Ensure package.json can be imported by consuming projects + ([PR#1870](https://github.com/cucumber/cucumber-js/pull/1870) + [Issue#1869](https://github.com/cucumber/cucumber-js/issues/1869)) - Allows for parentheses in paths for developers working on cucumber's own code ([[#1735](https://github.com/cucumber/cucumber-js/issues/1735)]) - Smoother onboarding for Windows developers ([#1863](https://github.com/cucumber/cucumber-js/pull/1863)) diff --git a/features/direct_imports.feature b/features/direct_imports.feature index a9ebd7250..1bebbb903 100644 --- a/features/direct_imports.feature +++ b/features/direct_imports.feature @@ -60,4 +60,26 @@ Feature: Core feature elements execution using direct imports Given(/^a step passes$/, function() {}); """ When I run cucumber-js - Then it passes \ No newline at end of file + Then it passes + + Scenario: we can import the version number from package.json and from the library + Given a file named "features/a.feature" with: + """ + Feature: some feature + Scenario: some scenario + Given a step checks the version number + """ + And a file named "features/step_definitions/cucumber_steps.js" with: + """ + const {Given} = require('@cucumber/cucumber') + const package_version = require('@cucumber/cucumber/package.json').version + const library_version = require('@cucumber/cucumber').version + + Given(/^a step checks the version number$/, function() { + if (package_version !== library_version) { + throw new Error(`package version: ${package_version} !== library version: ${library_version}`) + } + }); + """ + When I run cucumber-js + Then it passes diff --git a/package.json b/package.json index fcbdd9887..8f484a0ec 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,8 @@ }, "./lib/*": { "require": "./lib/*.js" - } + }, + "./package.json": "./package.json" }, "types": "./lib/index.d.ts", "engines": {