From 7cba5007b7044f5ef8db63af89de573e0c0fe343 Mon Sep 17 00:00:00 2001 From: David Goss Date: Sat, 5 Sep 2020 05:24:53 +0100 Subject: [PATCH] build: scoped package name (#1411) Co-authored-by: Charles Rudolph --- README.md | 2 +- features/ambiguous_step.feature | 2 +- features/attachments.feature | 16 +++---- .../before_after_all_hook_interfaces.feature | 22 ++++----- .../before_after_all_hook_timeouts.feature | 6 +-- features/before_after_all_hooks.feature | 6 +-- features/cli.feature | 4 +- features/core.feature | 8 ++-- features/custom_formatter.feature | 4 +- features/custom_stack_trace.feature | 2 +- features/data_tables.feature | 8 ++-- features/direct_imports.feature | 4 +- features/doc_string.feature | 4 +- features/dryrun_mode.feature | 8 ++-- features/error_formatting.feature | 8 ++-- features/exit.feature | 2 +- features/fail_fast.feature | 2 +- features/failing_steps.feature | 16 +++---- features/fake_time.feature | 4 +- features/formatter_paths.feature | 2 +- features/formatters.feature | 8 ++-- features/generator_step_definitions.feature | 4 +- features/global_install.feature | 2 +- features/handling_step_errors.feature | 2 +- features/hook_interface.feature | 24 +++++----- features/hook_parameter.feature | 8 ++-- features/hook_timeouts.feature | 2 +- features/hooks.feature | 14 +++--- features/language.feature | 2 +- features/multiple_formatters.feature | 2 +- features/multiple_hooks.feature | 6 +-- features/nested_features.feature | 2 +- features/order.feature | 2 +- features/parallel.feature | 4 +- features/parameter_types.feature | 14 +++--- features/passing_steps.feature | 6 +-- features/pending_steps.feature | 6 +-- features/profiles.feature | 2 +- features/require_module.feature | 2 +- features/rerun_formatter.feature | 2 +- features/rerun_formatter_subfolder.feature | 2 +- features/retry.feature | 28 +++++------ features/rule.feature | 4 +- features/skipped_steps.feature | 20 ++++---- features/step_definition_timeouts.feature | 2 +- features/step_wrapper_with_options.feature | 4 +- features/strict_mode.feature | 4 +- features/summary_formatter.feature | 2 +- features/support/hooks.ts | 48 ++++++++++++------- features/tagged_hooks.feature | 6 +-- .../target_specific_scenarios_by_tag.feature | 2 +- features/usage_formatter.feature | 4 +- features/usage_json_formatter.feature | 2 +- features/world_parameters.feature | 10 ++-- package.json | 2 +- src/cli/install_validator.ts | 18 +++++-- 56 files changed, 212 insertions(+), 190 deletions(-) diff --git a/README.md b/README.md index 527af6a74..47996f709 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Everyone interacting in this codebase and issue tracker is expected to follow th Cucumber.js is available as an npm module. ``` shell -$ npm install cucumber +$ npm install @cucumber/cucumber ``` ### Browser diff --git a/features/ambiguous_step.feature b/features/ambiguous_step.feature index 8c31bb094..88769f266 100644 --- a/features/ambiguous_step.feature +++ b/features/ambiguous_step.feature @@ -9,7 +9,7 @@ Feature: Ambiguous Steps """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a ambiguous step$/, function() {}); When(/^a (.*) step$/, function(status) {}); diff --git a/features/attachments.feature b/features/attachments.feature index b0e4507ac..3d721f7de 100644 --- a/features/attachments.feature +++ b/features/attachments.feature @@ -9,7 +9,7 @@ Feature: Attachments """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) """ @@ -17,7 +17,7 @@ Feature: Attachments Scenario: Attach a buffer Given a file named "features/support/hooks.js" with: """ - const {Before} = require('cucumber') + const {Before} = require('@cucumber/cucumber') Before(function() { this.attach(Buffer.from([137, 80, 78, 71]), 'image/png') @@ -31,7 +31,7 @@ Feature: Attachments Scenario: Attach a stream (callback) Given a file named "features/support/hooks.js" with: """ - const {Before} = require('cucumber') + const {Before} = require('@cucumber/cucumber') const stream = require('stream') Before(function(testCase, callback) { @@ -50,7 +50,7 @@ Feature: Attachments Scenario: Attach a stream (promise) Given a file named "features/support/hooks.js" with: """ - const {Before} = require('cucumber') + const {Before} = require('@cucumber/cucumber') const stream = require('stream') Before(function() { @@ -70,7 +70,7 @@ Feature: Attachments Scenario: Attach from a before hook Given a file named "features/support/hooks.js" with: """ - const {Before} = require('cucumber') + const {Before} = require('@cucumber/cucumber') Before(function() { this.attach("text") @@ -84,7 +84,7 @@ Feature: Attachments Scenario: Attach from an after hook Given a file named "features/support/hooks.js" with: """ - const {After} = require('cucumber') + const {After} = require('@cucumber/cucumber') After(function() { this.attach("text") @@ -98,7 +98,7 @@ Feature: Attachments Scenario: Attach from a step definition Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() { this.attach("text") @@ -113,7 +113,7 @@ Feature: Attachments Scenario: Attaching after hook/step finishes Given a file named "features/support/hooks.js" with: """ - const {After} = require('cucumber') + const {After} = require('@cucumber/cucumber') const Promise = require('bluebird') After(function() { diff --git a/features/before_after_all_hook_interfaces.feature b/features/before_after_all_hook_interfaces.feature index bf951ee35..683881627 100644 --- a/features/before_after_all_hook_interfaces.feature +++ b/features/before_after_all_hook_interfaces.feature @@ -15,7 +15,7 @@ Feature: before / after all hook interfaces """ And a file named "features/step_definitions/my_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given('first step', function() {}) Given('second step', function() {}) @@ -24,7 +24,7 @@ Feature: before / after all hook interfaces Scenario Outline: synchronous Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function() {}) """ @@ -39,7 +39,7 @@ Feature: before / after all hook interfaces Scenario Outline: synchronously throws Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function() { throw new Error('my error') @@ -56,7 +56,7 @@ Feature: before / after all hook interfaces Scenario Outline: callback without error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function(callback) { setTimeout(callback) @@ -73,7 +73,7 @@ Feature: before / after all hook interfaces Scenario Outline: callback with error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function(callback) { setTimeout(() => { @@ -97,7 +97,7 @@ Feature: before / after all hook interfaces Scenario Outline: callback asynchronously throws Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function(callback) { setTimeout(() => { @@ -120,7 +120,7 @@ Feature: before / after all hook interfaces Scenario Outline: callback - returning a promise Given a file named "features/step_definitions/failing_steps.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function(callback) { @@ -144,7 +144,7 @@ Feature: before / after all hook interfaces Scenario Outline: promise resolves Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function() { @@ -162,7 +162,7 @@ Feature: before / after all hook interfaces Scenario Outline: promise rejects with error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function() { @@ -184,7 +184,7 @@ Feature: before / after all hook interfaces Scenario Outline: promise rejects without error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function() { @@ -207,7 +207,7 @@ Feature: before / after all hook interfaces Scenario Outline: promise asynchronously throws Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function() { diff --git a/features/before_after_all_hook_timeouts.feature b/features/before_after_all_hook_timeouts.feature index d0e498eef..98b164e27 100644 --- a/features/before_after_all_hook_timeouts.feature +++ b/features/before_after_all_hook_timeouts.feature @@ -9,7 +9,7 @@ Feature: before / after all hook timeouts """ And a file named "features/step_definitions/steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}); """ @@ -17,7 +17,7 @@ Feature: before / after all hook timeouts Scenario Outline: slow handler timeout Given a file named "features/support/handlers.js" with: """ - const {, setDefaultTimeout} = require('cucumber') + const {, setDefaultTimeout} = require('@cucumber/cucumber') setDefaultTimeout(500) @@ -40,7 +40,7 @@ Feature: before / after all hook timeouts Scenario Outline: slow handlers can increase their timeout Given a file named "features/supports/handlers.js" with: """ - const {, setDefaultTimeout} = require('cucumber') + const {, setDefaultTimeout} = require('@cucumber/cucumber') setDefaultTimeout(500) diff --git a/features/before_after_all_hooks.feature b/features/before_after_all_hooks.feature index fbf7624f0..aef20594f 100644 --- a/features/before_after_all_hooks.feature +++ b/features/before_after_all_hooks.feature @@ -17,7 +17,7 @@ Feature: Environment Hooks Scenario: before all / after all hooks Given a file named "features/support/hooks.js" with: """ - const {AfterAll, BeforeAll, Given} = require('cucumber') + const {AfterAll, BeforeAll, Given} = require('@cucumber/cucumber') const {expect} = require('chai') let counter = 1 @@ -48,7 +48,7 @@ Feature: Environment Hooks Scenario: Failing before all hook kills the suite Given a file named "features/support/hooks.js" with: """ - const {BeforeAll} = require('cucumber') + const {BeforeAll} = require('@cucumber/cucumber') BeforeAll(function(callback) { callback(new Error('my error')) @@ -64,7 +64,7 @@ Feature: Environment Hooks Scenario: Failing after all hook kills the suite Given a file named "features/support/hooks.js" with: """ - const {AfterAll} = require('cucumber') + const {AfterAll} = require('@cucumber/cucumber') AfterAll(function(callback) { callback(new Error('my error')) diff --git a/features/cli.feature b/features/cli.feature index 13de21ac1..59beda6d5 100644 --- a/features/cli.feature +++ b/features/cli.feature @@ -12,7 +12,7 @@ Feature: Command line interface """ And a file named "step_definitions/cucumber_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a step is passing$/, function() {}) """ @@ -27,7 +27,7 @@ Feature: Command line interface """ And a file named "step_definitions/cucumber_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a step is passing$/, function() {}); """ diff --git a/features/core.feature b/features/core.feature index fe760ee60..89c2c4874 100644 --- a/features/core.feature +++ b/features/core.feature @@ -14,7 +14,7 @@ Feature: Core feature elements execution """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step passes$/, function() {}); """ @@ -43,7 +43,7 @@ Feature: Core feature elements execution """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given, Then, When} = require('cucumber') + const {Given, Then, When} = require('@cucumber/cucumber') Given(/^a "Given" step passes$/, function() {}) When(/^a "When" step passes$/, function() {}) @@ -68,7 +68,7 @@ Feature: Core feature elements execution """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {setWorldConstructor, Then, When} = require('cucumber') + const {setWorldConstructor, Then, When} = require('@cucumber/cucumber') const assert = require('assert') setWorldConstructor(function () { @@ -102,7 +102,7 @@ Feature: Core feature elements execution """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {setWorldConstructor, Then, When} = require('cucumber') + const {setWorldConstructor, Then, When} = require('@cucumber/cucumber') const assert = require('assert') setWorldConstructor(function () { diff --git a/features/custom_formatter.feature b/features/custom_formatter.feature index d01a6852b..e847fb061 100644 --- a/features/custom_formatter.feature +++ b/features/custom_formatter.feature @@ -10,7 +10,7 @@ Feature: custom formatter Scenario: extending Formatter Given a file named "simple_formatter.js" with: """ - const { Formatter, formatterHelpers, Status } = require('cucumber') + const { Formatter, formatterHelpers, Status } = require('@cucumber/cucumber') class SimpleFormatter extends Formatter { constructor(options) { @@ -65,7 +65,7 @@ Feature: custom formatter """ And a file named "simple_formatter.js" with: """ - const { SummaryFormatter, formatterHelpers, Status } = require('cucumber') + const { SummaryFormatter, formatterHelpers, Status } = require('@cucumber/cucumber') class SimpleFormatter extends SummaryFormatter { constructor(options) { diff --git a/features/custom_stack_trace.feature b/features/custom_stack_trace.feature index 270fc2972..4f940fb6f 100644 --- a/features/custom_stack_trace.feature +++ b/features/custom_stack_trace.feature @@ -10,7 +10,7 @@ Feature: Custom stack trace """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') const _prepareStackTrace = Error.prepareStackTrace; Error.prepareStackTrace = () => { return 'Custom message' } diff --git a/features/data_tables.feature b/features/data_tables.feature index b3f82165b..a8b4d6245 100644 --- a/features/data_tables.feature +++ b/features/data_tables.feature @@ -11,7 +11,7 @@ Feature: Data Tables """ Given a file named "features/step_definitions/passing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const assert = require('assert') Given(/^a table step$/, function(table) { @@ -38,7 +38,7 @@ Feature: Data Tables """ Given a file named "features/step_definitions/passing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const assert = require('assert') Given(/^a table step$/, function(table) { @@ -64,7 +64,7 @@ Feature: Data Tables """ Given a file named "features/step_definitions/passing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const assert = require('assert') Given(/^a table step$/, function(table) { @@ -91,7 +91,7 @@ Feature: Data Tables """ Given a file named "features/step_definitions/passing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const assert = require('assert') Given(/^a table step$/, function(table) { diff --git a/features/direct_imports.feature b/features/direct_imports.feature index 989eef786..c01905136 100644 --- a/features/direct_imports.feature +++ b/features/direct_imports.feature @@ -12,7 +12,7 @@ Feature: Core feature elements execution using direct imports """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step passes$/, function() {}); """ @@ -28,7 +28,7 @@ Feature: Core feature elements execution using direct imports """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step fails$/, function(callback) { callback(new Error('my error')) diff --git a/features/doc_string.feature b/features/doc_string.feature index 392cc65ba..11a3bc974 100644 --- a/features/doc_string.feature +++ b/features/doc_string.feature @@ -12,7 +12,7 @@ Feature: doc string """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const assert = require('assert') Given(/^a doc string step$/, function(docString) { @@ -35,7 +35,7 @@ Feature: doc string """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const assert = require('assert') Given(/^a "([^"]*)" step$/, function(type, docString) { diff --git a/features/dryrun_mode.feature b/features/dryrun_mode.feature index 94b69ff1a..a0f52ebda 100644 --- a/features/dryrun_mode.feature +++ b/features/dryrun_mode.feature @@ -13,7 +13,7 @@ Feature: Dryrun mode Scenario: default behavior Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given('a step', function() {}) """ @@ -24,7 +24,7 @@ Feature: Dryrun mode Scenario: ambiguous step Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given('a step', function() {}); Given('a(n) step', function() {}); @@ -41,7 +41,7 @@ Feature: Dryrun mode Scenario: hooks should not execute in dry run, serial runtime Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {BeforeAll, Before, After, AfterAll, Given} = require('cucumber') + const {BeforeAll, Before, After, AfterAll, Given} = require('@cucumber/cucumber') Before(function() {throw 'shouldnt run Before'}) After(function() {throw 'shouldnt run After'}) @@ -58,7 +58,7 @@ Feature: Dryrun mode Scenario: hooks should not execute in dry run, parallel runtime Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {BeforeAll, Before, After, AfterAll, Given} = require('cucumber') + const {BeforeAll, Before, After, AfterAll, Given} = require('@cucumber/cucumber') Before(function() {throw 'shouldnt run Before'}) After(function() {throw 'shouldnt run After'}) diff --git a/features/error_formatting.feature b/features/error_formatting.feature index af08c7214..4fe7c6b4c 100644 --- a/features/error_formatting.feature +++ b/features/error_formatting.feature @@ -8,13 +8,13 @@ Feature: Error formatting """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}) """ And a file named "features/support/hooks.js" with: """ - const {Before} = require('cucumber') + const {Before} = require('@cucumber/cucumber') Before(function(_, callback) { callback('Fail') }) """ @@ -51,7 +51,7 @@ Feature: Error formatting """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a basic step$/, function() { this.attach('Some info.') }) Given(/^a step with a doc string$/, function(str) { this.attach('{"name": "some JSON"}', 'application/json') }) @@ -88,7 +88,7 @@ Feature: Error formatting """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a table:$/, function(table) {}) Given(/^a pending step$/, function() { return 'pending' }) diff --git a/features/exit.feature b/features/exit.feature index 188e8615a..a9b73663e 100644 --- a/features/exit.feature +++ b/features/exit.feature @@ -13,7 +13,7 @@ Feature: Exit """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given, After} = require('cucumber') + const {Given, After} = require('@cucumber/cucumber') Given('a step', function() {}) diff --git a/features/fail_fast.feature b/features/fail_fast.feature index 8eef30116..60ea0a8d9 100644 --- a/features/fail_fast.feature +++ b/features/fail_fast.feature @@ -14,7 +14,7 @@ Feature: Fail fast """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a failing step$/, function() { throw 'fail' }) Given(/^a passing step$/, function() {}) diff --git a/features/failing_steps.feature b/features/failing_steps.feature index f8c864527..f2df82d0b 100644 --- a/features/failing_steps.feature +++ b/features/failing_steps.feature @@ -11,7 +11,7 @@ Feature: Failing steps Scenario: too few arguments Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a (.*) step$/, function() {}) """ @@ -25,7 +25,7 @@ Feature: Failing steps Scenario: too many arguments Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a failing step$/, function(arg1, arg2) {}) """ @@ -39,7 +39,7 @@ Feature: Failing steps Scenario: synchronous - throws Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a failing step$/, function() { throw new Error('my error'); @@ -56,7 +56,7 @@ Feature: Failing steps Scenario: asynchronous - throws Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a failing step$/, function(callback) { setTimeout(function() { @@ -74,7 +74,7 @@ Feature: Failing steps Scenario: asynchronous - passing error as first argument to the callback Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a failing step$/, function(callback) { setTimeout(function() { @@ -92,7 +92,7 @@ Feature: Failing steps Scenario: asynchronous - using a callback and returning a promise Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') const Promise = require('bluebird') When(/^a failing step$/, function(callback) { @@ -112,7 +112,7 @@ Feature: Failing steps Scenario: promise - throws Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') const Promise = require('bluebird') When(/^a failing step$/, function() { @@ -133,7 +133,7 @@ Feature: Failing steps Scenario: promise - rejects Given a file named "features/step_definitions/failing_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') const Promise = require('bluebird') When(/^a failing step$/, function() { diff --git a/features/fake_time.feature b/features/fake_time.feature index 7e9f00240..1151bcc1e 100644 --- a/features/fake_time.feature +++ b/features/fake_time.feature @@ -2,7 +2,7 @@ Feature: Allow time to be faked by utilities such as sinon.useFakeTimers Background: Before and After hooks to enable faking time. Given a file named "features/support/hooks.js" with: """ - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') const sinon = require('sinon') Before(function(scenario) { @@ -25,7 +25,7 @@ Feature: Allow time to be faked by utilities such as sinon.useFakeTimers Given a file named "features/step_definitions/passing_steps.js" with: """ const assert = require('assert') - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const sinon = require('sinon') Given(/^a faked time step$/, function () { diff --git a/features/formatter_paths.feature b/features/formatter_paths.feature index ccc3ea7cf..e9bb7cb6d 100644 --- a/features/formatter_paths.feature +++ b/features/formatter_paths.feature @@ -9,7 +9,7 @@ Feature: Formatter Paths """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}) """ diff --git a/features/formatters.feature b/features/formatters.feature index fbb3fe1b4..c769f352d 100644 --- a/features/formatters.feature +++ b/features/formatters.feature @@ -20,7 +20,7 @@ Feature: Formatters """ Given a file named "features/step_definitions/steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) """ @@ -38,7 +38,7 @@ Feature: Formatters """ Given a file named "features/step_definitions/steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) """ @@ -55,7 +55,7 @@ Feature: Formatters """ Given a file named "features/step_definitions/steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function(callback) { callback(new Error('my error')) }) """ @@ -73,7 +73,7 @@ Feature: Formatters """ Given a file named "features/step_definitions/steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false diff --git a/features/generator_step_definitions.feature b/features/generator_step_definitions.feature index 146b41213..a9f520286 100644 --- a/features/generator_step_definitions.feature +++ b/features/generator_step_definitions.feature @@ -14,7 +14,7 @@ Feature: Generator Step Definitions And a file named "features/step_definitions/cucumber_steps.js" with: """ const assert = require('assert') - const {setWorldConstructor, Then, When} = require('cucumber') + const {setWorldConstructor, Then, When} = require('@cucumber/cucumber') setWorldConstructor(function () { this.context = "" @@ -47,7 +47,7 @@ Feature: Generator Step Definitions """ const isGenerator = require('is-generator') const {coroutine} = require('bluebird') - const {setDefinitionFunctionWrapper} = require('cucumber') + const {setDefinitionFunctionWrapper} = require('@cucumber/cucumber') setDefinitionFunctionWrapper(function (fn) { if (isGenerator.fn(fn)) { diff --git a/features/global_install.feature b/features/global_install.feature index d652b2d7b..b34f049b9 100644 --- a/features/global_install.feature +++ b/features/global_install.feature @@ -10,7 +10,7 @@ Feature: Global Installs """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a step is passing$/, function() {}) """ diff --git a/features/handling_step_errors.feature b/features/handling_step_errors.feature index 122e30c18..55ab8bb13 100644 --- a/features/handling_step_errors.feature +++ b/features/handling_step_errors.feature @@ -11,7 +11,7 @@ Feature: Handling step errors """ Given a file named "features/step_definitions/step_definitions.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given('I pass an error to the callback', function (cb) { var unusualErrorObject = {} diff --git a/features/hook_interface.feature b/features/hook_interface.feature index 6410a612e..9fab4031d 100644 --- a/features/hook_interface.feature +++ b/features/hook_interface.feature @@ -9,7 +9,7 @@ Feature: After hook interface """ And a file named "features/step_definitions/my_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a step$/, function() { this.value = 1; @@ -19,7 +19,7 @@ Feature: After hook interface Scenario Outline: too many arguments Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function(arg1, arg2, arg3) {}) """ @@ -38,7 +38,7 @@ Feature: After hook interface Scenario Outline: synchronous Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const assert = require('assert') (function() {}) @@ -54,7 +54,7 @@ Feature: After hook interface Scenario Outline: synchronously throws Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function() { throw new Error('my error') @@ -71,7 +71,7 @@ Feature: After hook interface Scenario Outline: callback without error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const assert = require('assert') (function(scenario, callback) { @@ -89,7 +89,7 @@ Feature: After hook interface Scenario Outline: callback with error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function(scenario, callback) { setTimeout(() => { @@ -109,7 +109,7 @@ Feature: After hook interface Scenario Outline: callback asynchronously throws Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') (function(scenario, callback) { setTimeout(() => { @@ -128,7 +128,7 @@ Feature: After hook interface Scenario Outline: callback - returning a promise Given a file named "features/step_definitions/failing_steps.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function(scenario, callback) { @@ -152,7 +152,7 @@ Feature: After hook interface Scenario Outline: promise resolves Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function() { @@ -170,7 +170,7 @@ Feature: After hook interface Scenario Outline: promise rejects with error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function(){ @@ -192,7 +192,7 @@ Feature: After hook interface Scenario Outline: promise rejects without error Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function() { @@ -215,7 +215,7 @@ Feature: After hook interface Scenario Outline: promise asynchronously throws Given a file named "features/support/hooks.js" with: """ - const {} = require('cucumber') + const {} = require('@cucumber/cucumber') const Promise = require('bluebird') (function(){ diff --git a/features/hook_parameter.feature b/features/hook_parameter.feature index 87fe675ee..e8682935d 100644 --- a/features/hook_parameter.feature +++ b/features/hook_parameter.feature @@ -10,13 +10,13 @@ Feature: Hook Parameters """ And a file named "features/step_definitions/my_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a step$/, function() {}) """ And a file named "features/support/hooks.js" with: """ - const {Before, formatterHelpers} = require('cucumber') + const {Before, formatterHelpers} = require('@cucumber/cucumber') Before(function({pickle, gherkinDocument}) { const { line } = formatterHelpers.PickleParser.getPickleLocation({ gherkinDocument, pickle }) @@ -46,14 +46,14 @@ Feature: Hook Parameters """ And a file named "features/step_definitions/my_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^a passing step$/, function() {}) When(/^a failing step$/, function() { throw new Error("my error") }) """ And a file named "features/support/hooks.js" with: """ - const { After, formatterHelpers, Status } = require('cucumber') + const { After, formatterHelpers, Status } = require('@cucumber/cucumber') After(function({pickle, gherkinDocument, result}) { const { line } = formatterHelpers.PickleParser.getPickleLocation({ gherkinDocument, pickle }) diff --git a/features/hook_timeouts.feature b/features/hook_timeouts.feature index 35e2ceee3..1607f1fd8 100644 --- a/features/hook_timeouts.feature +++ b/features/hook_timeouts.feature @@ -3,7 +3,7 @@ Feature: Step definition timeouts Background: Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Before, Given, setDefaultTimeout} = require('cucumber') + const {Before, Given, setDefaultTimeout} = require('@cucumber/cucumber') setDefaultTimeout(500); diff --git a/features/hooks.feature b/features/hooks.feature index d769a8573..628bfbf32 100644 --- a/features/hooks.feature +++ b/features/hooks.feature @@ -9,7 +9,7 @@ Feature: Environment Hooks """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) """ @@ -17,7 +17,7 @@ Feature: Environment Hooks Scenario: Hooks are steps Given a file named "features/support/hooks.js" with: """ - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') Before(function() {}) After(function() {}) @@ -32,7 +32,7 @@ Feature: Environment Hooks Scenario: Failing before fails the scenario Given a file named "features/support/hooks.js" with: """ - const {Before} = require('cucumber') + const {Before} = require('@cucumber/cucumber') Before(function() { throw 'Fail' }) """ @@ -43,7 +43,7 @@ Feature: Environment Hooks Scenario: Failing after hook fails the scenario Given a file named "features/support/hooks.js" with: """ - const {After} = require('cucumber') + const {After} = require('@cucumber/cucumber') After(function() { throw 'Fail' }) """ @@ -54,7 +54,7 @@ Feature: Environment Hooks Scenario: After hooks still execute after a failure Given a file named "features/support/hooks.js" with: """ - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') Before(function() { throw 'Fail' }) After(function() {}) @@ -66,7 +66,7 @@ Feature: Environment Hooks Scenario: World is this in hooks Given a file named "features/support/world.js" with: """ - const {setWorldConstructor} = require('cucumber') + const {setWorldConstructor} = require('@cucumber/cucumber') function WorldConstructor() { return { @@ -78,7 +78,7 @@ Feature: Environment Hooks """ Given a file named "features/support/hooks.js" with: """ - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') Before(function() { if (!this.isWorld()) { diff --git a/features/language.feature b/features/language.feature index 735c599f6..e4bbe2790 100644 --- a/features/language.feature +++ b/features/language.feature @@ -9,7 +9,7 @@ Feature: Multiple Formatters """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^une étape$/, function() {}) """ diff --git a/features/multiple_formatters.feature b/features/multiple_formatters.feature index e426c8058..624f879df 100644 --- a/features/multiple_formatters.feature +++ b/features/multiple_formatters.feature @@ -9,7 +9,7 @@ Feature: Multiple Formatters """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}) """ diff --git a/features/multiple_hooks.feature b/features/multiple_hooks.feature index 8546e98c3..dffd570e6 100644 --- a/features/multiple_hooks.feature +++ b/features/multiple_hooks.feature @@ -13,7 +13,7 @@ Feature: Multiple Hooks """ And a file named "features/step_definitions/world.js" with: """ - const {setWorldConstructor} = require('cucumber') + const {setWorldConstructor} = require('@cucumber/cucumber') setWorldConstructor(function() { this.value = 0 @@ -22,13 +22,13 @@ Feature: Multiple Hooks And a file named "features/step_definitions/my_steps.js" with: """ const assert = require('assert') - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given('a step', function() {}) """ And a file named "features/step_definitions/hooks.js" with: """ - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') const assert = require('assert') Before(function() { diff --git a/features/nested_features.feature b/features/nested_features.feature index 425b7b5e9..a91ee6875 100644 --- a/features/nested_features.feature +++ b/features/nested_features.feature @@ -13,7 +13,7 @@ Feature: Automatically required support files for nested features """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) """ diff --git a/features/order.feature b/features/order.feature index cb07c8508..a2296332f 100644 --- a/features/order.feature +++ b/features/order.feature @@ -25,7 +25,7 @@ Feature: Set the execution order """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) """ diff --git a/features/parallel.feature b/features/parallel.feature index 643f3f655..686627ede 100644 --- a/features/parallel.feature +++ b/features/parallel.feature @@ -3,7 +3,7 @@ Feature: Running scenarios in parallel Scenario: running in parallel can improve speed if there are async operations Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const Promise = require('bluebird') Given(/^a slow step$/, function(callback) { @@ -26,7 +26,7 @@ Feature: Running scenarios in parallel Scenario: an error in BeforeAll fails the test Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {BeforeAll, Given} = require('cucumber') + const {BeforeAll, Given} = require('@cucumber/cucumber') const Promise = require('bluebird') Given(/^a slow step$/, function(callback) { diff --git a/features/parameter_types.feature b/features/parameter_types.feature index 3ae46b4d3..50e6d1a2a 100644 --- a/features/parameter_types.feature +++ b/features/parameter_types.feature @@ -14,7 +14,7 @@ Feature: Parameter types Given a file named "features/step_definitions/my_steps.js" with: """ const assert = require('assert') - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given('a {param} step', function(param) { assert.equal(param, 'PARTICULAR') @@ -24,7 +24,7 @@ Feature: Parameter types Scenario: delegate transform to world Given a file named "features/support/transforms.js" with: """ - const {setWorldConstructor, defineParameterType} = require('cucumber') + const {setWorldConstructor, defineParameterType} = require('@cucumber/cucumber') defineParameterType({ regexp: /particular/, @@ -47,7 +47,7 @@ Feature: Parameter types Scenario: sync transform (success) Given a file named "features/support/transforms.js" with: """ - const {defineParameterType} = require('cucumber') + const {defineParameterType} = require('@cucumber/cucumber') defineParameterType({ regexp: /particular/, @@ -61,7 +61,7 @@ Feature: Parameter types Scenario: sync transform (error) Given a file named "features/support/transforms.js" with: """ - const {defineParameterType} = require('cucumber') + const {defineParameterType} = require('@cucumber/cucumber') defineParameterType({ regexp: /particular/, @@ -81,7 +81,7 @@ Feature: Parameter types Scenario: no transform Given a file named "features/support/transforms.js" with: """ - const {defineParameterType} = require('cucumber') + const {defineParameterType} = require('@cucumber/cucumber') defineParameterType({ regexp: /particular/, @@ -98,7 +98,7 @@ Feature: Parameter types Scenario: async transform (success) Given a file named "features/step_definitions/particular_steps.js" with: """ - const {defineParameterType} = require('cucumber') + const {defineParameterType} = require('@cucumber/cucumber') defineParameterType({ regexp: /particular/, @@ -112,7 +112,7 @@ Feature: Parameter types Scenario: async transform (error) Given a file named "features/step_definitions/particular_steps.js" with: """ - const {defineParameterType} = require('cucumber') + const {defineParameterType} = require('@cucumber/cucumber') const Promise = require('bluebird') defineParameterType({ diff --git a/features/passing_steps.feature b/features/passing_steps.feature index b7e7dab17..9d33627f5 100644 --- a/features/passing_steps.feature +++ b/features/passing_steps.feature @@ -11,7 +11,7 @@ Feature: Passing steps Scenario: synchronous Given a file named "features/step_definitions/passing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}) """ @@ -21,7 +21,7 @@ Feature: Passing steps Scenario: asynchronous Given a file named "features/step_definitions/passing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function(callback) { setTimeout(callback) @@ -33,7 +33,7 @@ Feature: Passing steps Scenario: promise Given a file named "features/step_definitions/passing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') const Promise = require('bluebird') Given(/^a passing step$/, function() { diff --git a/features/pending_steps.feature b/features/pending_steps.feature index 444bcc487..883ec6acb 100644 --- a/features/pending_steps.feature +++ b/features/pending_steps.feature @@ -11,7 +11,7 @@ Feature: Pending steps Scenario: Synchronous pending step Given a file named "features/step_definitions/failing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a pending step$/, function() { return 'pending' @@ -25,7 +25,7 @@ Feature: Pending steps Scenario: Callback pending step Given a file named "features/step_definitions/failing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a pending step$/, function(callback) { callback(null, 'pending') @@ -38,7 +38,7 @@ Feature: Pending steps Scenario: Promise pending step Given a file named "features/step_definitions/failing_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a pending step$/, function(){ return { diff --git a/features/profiles.feature b/features/profiles.feature index 3826f3839..97b17a2fe 100644 --- a/features/profiles.feature +++ b/features/profiles.feature @@ -12,7 +12,7 @@ Feature: default command line arguments """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}) """ diff --git a/features/require_module.feature b/features/require_module.feature index 19d01ef0c..bbea31d60 100644 --- a/features/require_module.feature +++ b/features/require_module.feature @@ -14,7 +14,7 @@ Feature: compilers """ Given a file named "features/step_definitions/cucumber_steps.coffee" with: """ - {Given} = require 'cucumber' + {Given} = require '@cucumber/cucumber' Given /^a step$/, -> """ diff --git a/features/rerun_formatter.feature b/features/rerun_formatter.feature index 6e0f27294..33bda2080 100644 --- a/features/rerun_formatter.feature +++ b/features/rerun_formatter.feature @@ -36,7 +36,7 @@ Feature: Rerun Formatter """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}) Given(/^a failing step$/, function() { throw 'fail' }) diff --git a/features/rerun_formatter_subfolder.feature b/features/rerun_formatter_subfolder.feature index 65bb68849..7a2ac9279 100644 --- a/features/rerun_formatter_subfolder.feature +++ b/features/rerun_formatter_subfolder.feature @@ -16,7 +16,7 @@ Feature: Rerun Formatter """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a passing step$/, function() {}) Given(/^a failing step$/, function() { throw 'fail' }) diff --git a/features/retry.feature b/features/retry.feature index 33b3bf99a..accf8d388 100644 --- a/features/retry.feature +++ b/features/retry.feature @@ -22,7 +22,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) """ @@ -50,7 +50,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a failing step$/, function() { throw 'fail' }) """ @@ -70,7 +70,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a failing step$/, function() { throw 'fail' }) """ @@ -90,7 +90,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -130,7 +130,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -172,7 +172,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -220,7 +220,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -269,7 +269,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -328,7 +328,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a failing step$/, function() { throw 'fail' }) """ @@ -353,7 +353,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -380,7 +380,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -409,7 +409,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -453,7 +453,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') let willPass = false @@ -502,7 +502,7 @@ Feature: Retry flaky tests """ Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Before, After, Given, setWorldConstructor} = require('cucumber') + const {Before, After, Given, setWorldConstructor} = require('@cucumber/cucumber') Before(function() { this.usedCount++ diff --git a/features/rule.feature b/features/rule.feature index 9af7bb866..e4b56fd6d 100644 --- a/features/rule.feature +++ b/features/rule.feature @@ -21,7 +21,7 @@ Feature: Rule keyword """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given, When, Then} = require('cucumber') + const {Given, When, Then} = require('@cucumber/cucumber') Given('there are {int} ninjas', function(count) { this.total = count @@ -84,7 +84,7 @@ Feature: Rule keyword """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given, When, Then} = require('cucumber') + const {Given, When, Then} = require('@cucumber/cucumber') Given('there are {int} ninjas', function(count) { this.total = count diff --git a/features/skipped_steps.feature b/features/skipped_steps.feature index e4c571030..fbc30b551 100644 --- a/features/skipped_steps.feature +++ b/features/skipped_steps.feature @@ -17,7 +17,7 @@ Feature: Skipped steps Scenario: Synchronous skipped step Given a file named "features/step_definitions/skipped_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a skipped step$/, function() { return 'skipped' @@ -32,7 +32,7 @@ Feature: Skipped steps Scenario: Callback skipped step Given a file named "features/step_definitions/skipped_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a skipped step$/, function(callback) { callback(null, 'skipped') @@ -46,7 +46,7 @@ Feature: Skipped steps Scenario: Promise skipped step Given a file named "features/step_definitions/skipped_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a skipped step$/, function(){ return { @@ -66,13 +66,13 @@ Feature: Skipped steps Scenario: Hook skipped scenario steps Given a file named "features/support/hooks.js" with: """ - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') Before(function() {return 'skipped'}) """ And a file named "features/step_definitions/skipped_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a skipped step$/, function() { var a = 1; @@ -86,7 +86,7 @@ Feature: Skipped steps Scenario: Skipped before hook should skip all before hooks Given a file named "features/step_definitions/world.js" with: """ - const {setWorldConstructor} = require('cucumber') + const {setWorldConstructor} = require('@cucumber/cucumber') setWorldConstructor(function() { this.ran = false }) @@ -94,7 +94,7 @@ Feature: Skipped steps And a file named "features/support/hooks.js" with: """ const assert = require('assert') - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') Before(function() {return 'skipped'}) @@ -104,7 +104,7 @@ Feature: Skipped steps """ And a file named "features/step_definitions/skipped_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a skipped step$/, function() { var a = 1; @@ -117,7 +117,7 @@ Feature: Skipped steps Scenario: Skipped before hook should run after hook Given a file named "features/support/hooks.js" with: """ - const {After, Before} = require('cucumber') + const {After, Before} = require('@cucumber/cucumber') Before(function() {return 'skipped'}) @@ -127,7 +127,7 @@ Feature: Skipped steps """ And a file named "features/step_definitions/skipped_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a skipped step$/, function() { var a = 1; diff --git a/features/step_definition_timeouts.feature b/features/step_definition_timeouts.feature index a1ebc0b7d..39a45864c 100644 --- a/features/step_definition_timeouts.feature +++ b/features/step_definition_timeouts.feature @@ -3,7 +3,7 @@ Feature: Step definition timeouts Background: Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given, setDefaultTimeout} = require('cucumber') + const {Given, setDefaultTimeout} = require('@cucumber/cucumber') const Promise = require('bluebird') setDefaultTimeout(500) diff --git a/features/step_wrapper_with_options.feature b/features/step_wrapper_with_options.feature index 855110d2b..63f7428f8 100644 --- a/features/step_wrapper_with_options.feature +++ b/features/step_wrapper_with_options.feature @@ -13,13 +13,13 @@ Feature: Step Wrapper with Options """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^I run a step with options$/, {wrapperOptions: {retry: 2}}, function () {}) """ And a file named "features/support/setup.js" with: """ - const {setDefinitionFunctionWrapper} = require('cucumber') + const {setDefinitionFunctionWrapper} = require('@cucumber/cucumber') setDefinitionFunctionWrapper(function (fn, options = {}) { if (options.retry) { diff --git a/features/strict_mode.feature b/features/strict_mode.feature index 853f27b9d..0adf874b9 100644 --- a/features/strict_mode.feature +++ b/features/strict_mode.feature @@ -14,7 +14,7 @@ Feature: Strict mode Scenario: Fail with pending step by default Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() { return 'pending' }) """ @@ -24,7 +24,7 @@ Feature: Strict mode Scenario: Succeed with pending step with --no-strict Given a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() { return 'pending' }) """ diff --git a/features/summary_formatter.feature b/features/summary_formatter.feature index 0895eabe8..50a40897a 100644 --- a/features/summary_formatter.feature +++ b/features/summary_formatter.feature @@ -25,7 +25,7 @@ Feature: Summary Formatter """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step$/, function() {}) Given(/^another step$/, function() {}) diff --git a/features/support/hooks.ts b/features/support/hooks.ts index c5179ebec..5c49daf43 100644 --- a/features/support/hooks.ts +++ b/features/support/hooks.ts @@ -8,8 +8,6 @@ import { World } from './world' import { ITestCaseHookParameter } from '../../src/support_code_library_builder/types' const projectPath = path.join(__dirname, '..', '..') -const projectNodeModulesPath = path.join(projectPath, 'node_modules') -const moduleNames = fs.readdirSync(projectNodeModulesPath) Before('@debug', function (this: World) { this.debug = true @@ -36,7 +34,11 @@ Before(function ( fsExtra.removeSync(this.tmpDir) const tmpDirNodeModulesPath = path.join(this.tmpDir, 'node_modules') - const tmpDirCucumberPath = path.join(tmpDirNodeModulesPath, 'cucumber') + const tmpDirCucumberPath = path.join( + tmpDirNodeModulesPath, + '@cucumber', + 'cucumber' + ) fsExtra.ensureSymlinkSync(projectPath, tmpDirCucumberPath) this.localExecutablePath = path.join(projectPath, 'bin', 'cucumber-js') }) @@ -44,25 +46,37 @@ Before(function ( Before('@global-install', function (this: World) { const tmpObject = tmp.dirSync({ unsafeCleanup: true }) + // Symlink everything in node_modules so the fake global install has all the dependencies it needs + const projectNodeModulesPath = path.join(projectPath, 'node_modules') + const projectNodeModulesDirs = fs.readdirSync(projectNodeModulesPath) const globalInstallNodeModulesPath = path.join(tmpObject.name, 'node_modules') - moduleNames.forEach((moduleName) => { - const globalInstallNodeModulePath = path.join( - globalInstallNodeModulesPath, - moduleName - ) - const projectNodeModulePath = path.join( - projectPath, - 'node_modules', - moduleName - ) - fsExtra.ensureSymlinkSync( - projectNodeModulePath, - globalInstallNodeModulePath - ) + projectNodeModulesDirs.forEach((nodeModuleDir) => { + let pathsToLink = [nodeModuleDir] + if (nodeModuleDir[0] === '@') { + const scopeNodeModuleDirs = fs.readdirSync( + path.join(projectNodeModulesPath, nodeModuleDir) + ) + pathsToLink = scopeNodeModuleDirs.map((x) => path.join(nodeModuleDir, x)) + } + pathsToLink.forEach((pathToLink) => { + const globalInstallNodeModulePath = path.join( + globalInstallNodeModulesPath, + pathToLink + ) + const projectNodeModulePath = path.join( + projectNodeModulesPath, + pathToLink + ) + fsExtra.ensureSymlinkSync( + projectNodeModulePath, + globalInstallNodeModulePath + ) + }) }) const globalInstallCucumberPath = path.join( globalInstallNodeModulesPath, + '@cucumber', 'cucumber' ) const itemsToCopy = ['bin', 'lib', 'package.json'] diff --git a/features/tagged_hooks.feature b/features/tagged_hooks.feature index 9328ae006..d103cd0cb 100644 --- a/features/tagged_hooks.feature +++ b/features/tagged_hooks.feature @@ -6,7 +6,7 @@ Feature: Tagged Hooks Background: Given a file named "features/step_definitions/world.js" with: """ - const {setWorldConstructor} = require('cucumber') + const {setWorldConstructor} = require('@cucumber/cucumber') setWorldConstructor(function() { this.foo = false @@ -16,7 +16,7 @@ Feature: Tagged Hooks And a file named "features/step_definitions/my_steps.js" with: """ const assert = require('assert') - const {Then} = require('cucumber') + const {Then} = require('@cucumber/cucumber') Then('{word} is true', function(prop) { assert.equal(true, this[prop]) @@ -28,7 +28,7 @@ Feature: Tagged Hooks """ And a file named "features/step_definitions/my_tagged_hooks.js" with: """ - const {Before} = require('cucumber') + const {Before} = require('@cucumber/cucumber') Before({tags: '@foo'}, function() { this.foo = true diff --git a/features/target_specific_scenarios_by_tag.feature b/features/target_specific_scenarios_by_tag.feature index 6a11d4be8..5bc1beca6 100644 --- a/features/target_specific_scenarios_by_tag.feature +++ b/features/target_specific_scenarios_by_tag.feature @@ -28,7 +28,7 @@ Feature: Target specific scenarios """ And a file named "features/step_definitions/cucumber_steps.js" with: """ - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^a step is (.*)$/, function() {}) """ diff --git a/features/usage_formatter.feature b/features/usage_formatter.feature index 597a93586..a53a2d9cd 100644 --- a/features/usage_formatter.feature +++ b/features/usage_formatter.feature @@ -17,7 +17,7 @@ Feature: usage formatter """ And a file named "features/step_definitions/steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When('step A', function(callback) { setTimeout(callback, 100) }); When(/^(slow )?step B$/, function(slow, callback) { @@ -68,7 +68,7 @@ Feature: usage formatter """ And a file named "features/step_definitions/steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When(/^(slow )?step$/, function(slow, callback) { if (slow) { diff --git a/features/usage_json_formatter.feature b/features/usage_json_formatter.feature index e85574ac2..bd72a0de3 100644 --- a/features/usage_json_formatter.feature +++ b/features/usage_json_formatter.feature @@ -17,7 +17,7 @@ Feature: usage json formatter """ And a file named "features/step_definitions/steps.js" with: """ - const {When} = require('cucumber') + const {When} = require('@cucumber/cucumber') When('step A', function() {}); When('step B', function() {}); diff --git a/features/world_parameters.feature b/features/world_parameters.feature index 78514abda..057d7b9a7 100644 --- a/features/world_parameters.feature +++ b/features/world_parameters.feature @@ -37,7 +37,7 @@ Feature: World Parameters Given a file named "features/step_definitions/my_steps.js" with: """ const assert = require('assert') - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^the world parameters are correct$/, function() { assert.deepEqual(this.parameters, {}) @@ -50,7 +50,7 @@ Feature: World Parameters Given a file named "features/step_definitions/my_steps.js" with: """ const assert = require('assert') - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^the world parameters are correct$/, function() { assert.equal(this.parameters.a, 1) @@ -63,7 +63,7 @@ Feature: World Parameters Given a file named "features/step_definitions/my_steps.js" with: """ const assert = require('assert') - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^the world parameters are correct$/, function() { assert.equal(this.parameters.a, 3) @@ -76,7 +76,7 @@ Feature: World Parameters Scenario: custom world constructor is passed the parameters Given a file named "features/support/world.js" with: """ - const {setWorldConstructor} = require('cucumber') + const {setWorldConstructor} = require('@cucumber/cucumber') function CustomWorld(options) { for(const key in options.parameters) { @@ -89,7 +89,7 @@ Feature: World Parameters Given a file named "features/step_definitions/my_steps.js" with: """ const assert = require('assert') - const {Given} = require('cucumber') + const {Given} = require('@cucumber/cucumber') Given(/^the world parameters are correct$/, function() { assert.equal(this.a, 1) diff --git a/package.json b/package.json index 4b29a8438..38f3f2204 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "cucumber", + "name": "@cucumber/cucumber", "description": "The official JavaScript implementation of Cucumber.", "keywords": [ "testing", diff --git a/src/cli/install_validator.ts b/src/cli/install_validator.ts index d509ae264..6396dd5ca 100644 --- a/src/cli/install_validator.ts +++ b/src/cli/install_validator.ts @@ -9,11 +9,19 @@ export async function validateInstall(cwd: string): Promise { return // cucumber testing itself } const currentCucumberPath = require.resolve(projectPath) - let localCucumberPath: string = await promisify( - resolve - )('cucumber', { - basedir: cwd, - }) + let localCucumberPath: string + try { + localCucumberPath = await promisify(resolve)( + '@cucumber/cucumber', + { + basedir: cwd, + } + ) + } catch (e) { + throw new Error( + '`@cucumber/cucumber` module not resolvable. Must be locally installed.' + ) + } localCucumberPath = await fs.realpath(localCucumberPath) if (localCucumberPath !== currentCucumberPath) { throw new Error(