Implementation:Nightwatchjs Nightwatch Cucumber CLI Execution
| Knowledge Sources | |
|---|---|
| Domains | Testing, BDD, CLI |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
CLI command for executing Cucumber BDD tests with Nightwatch using a Cucumber-specific configuration file and Cucumber-native options.
Description
Running npx nightwatch --config cucumber-config.js with a configuration that has test_runner.type: 'cucumber' activates the Cucumber execution pipeline. The CLI supports Cucumber-specific flags: --tags for scenario filtering, --format for output formatters, --parallel for worker threads, --dry-run for validation, and --fail-fast for early abort.
Usage
Run Cucumber tests via the Nightwatch CLI specifying the Cucumber config file. Pass Cucumber-specific options as needed.
Code Reference
Source Location
- Repository: nightwatch
- File: bin/runner.js (lines 1-41)
- File: examples/cucumber-js/README.md (lines 56-80)
Signature
npx nightwatch [step_definitions_path] --config path/to/cucumber-config.js [options]
# Options:
# --config <path> Path to Cucumber-specific Nightwatch config
# --parallel <N> Number of worker threads
# --tags <expr> Cucumber tag expression (e.g., "@smoke and not @wip")
# --format <name> Cucumber formatter (progress, json, junit)
# --format-options <json> Formatter configuration
# --dry-run Parse and validate without executing
# --fail-fast Stop on first failure
Import
# CLI command - no import required
npx nightwatch --config cucumber-config.js
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| --config | string | Yes | Path to Cucumber-specific Nightwatch configuration |
| step_definitions_path | string | No | Path to step definition files (or use src_folders in config) |
| --tags | string | No | Cucumber tag expression for scenario filtering |
| --parallel | number | No | Number of parallel worker threads |
| --format | string | No | Output formatter name (default: 'progress') |
| --dry-run | flag | No | Validate without executing |
| --fail-fast | flag | No | Abort on first failure |
Outputs
| Name | Type | Description |
|---|---|---|
| Cucumber formatter output | string | Progress bars, JSON, or JUnit XML output |
| Exit code | number | 0 = all passed, non-zero = failures |
Usage Examples
Run Cucumber Tests
# Run all Cucumber tests
npx nightwatch --config test/cucumber-config.js
# Run with specific tag
npx nightwatch --config test/cucumber-config.js --tags "@smoke"
# Run with JSON formatter
npx nightwatch --config test/cucumber-config.js --format json
# Run in parallel with 4 workers
npx nightwatch --config test/cucumber-config.js --parallel 4
# Dry run (validate without executing)
npx nightwatch --config test/cucumber-config.js --dry-run
# Fail fast on first failure
npx nightwatch --config test/cucumber-config.js --fail-fast