CLI

January 15, 2024 ยท View on GitHub

Cucumber includes an executable file to run your scenarios. After installing the @cucumber/cucumber package, you can run it directly:

./node_modules/.bin/cucumber-js

Or via a package.json script:

{
  "scripts": {
    "cucumber": "cucumber-js"
  }
}

Or via npx:

npx cucumber-js

Options

All the standard configuration options can be provided via the CLI.

Additionally, there are a few options that are specific to the CLI:

OptionTypeRepeatableDescription
--config, -cstringNoPath to your configuration file - see Files
--profile, -pstring[]YesProfiles from which to include configuration - see Profiles
--version, -vbooleanNoPrint the currently installed version of Cucumber, then exit immediately
--i18n-keywordsstringNoPrint the Gherkin keywords for the given ISO-639-1 language code, then exit immediately
--i18n-languagesbooleanNoPrint the supported languages for Gherkin, then exit immediately

To see the available options for your installed version, run:

cucumber-js --help

Exiting

By default, cucumber exits when the event loop drains. Use the forceExit configuration option in order to force shutdown of the event loop when the test run has finished:

  • In a configuration file { forceExit: true }
  • On the CLI cucumber-js --force-exit

This is discouraged, as fixing the issues that causes the hang is a better long term solution. Some potential resources for that are: