Cucumber includes an executable file to run your scenarios. After installing the @cucumber/cucumber package, you can run it directly:
./node_modules/.bin/cucumber-jsOr via a package.json script:
{
"scripts": {
"cucumber": "cucumber-js"
}
}Or via npx:
npx cucumber-jsAll the standard configuration options can be provided via the CLI.
Additionally, there are a few options that are specific to the CLI:
| Option | Type | Repeatable | Description |
|---|---|---|---|
--config, -c |
string |
No | Path to your configuration file - see Files |
--profile, -p |
string[] |
Yes | Profiles from which to include configuration - see Profiles |
--version, -v |
boolean |
No | Print the currently installed version of Cucumber, then exit immediately |
--i18n-keywords |
string |
No | Print the Gherkin keywords for the given ISO-639-1 language code, then exit immediately |
--i18n-languages |
boolean |
No | Print the supported languages for Gherkin, then exit immediately |
To see the available options for your installed version, run:
cucumber-js --helpBy 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:
- Node.js guide to debugging
- NPM package why-is-node-running
- Node.js Async Hooks
- Isolating what scenario or scenarios causes the hang