Implementation:Nightwatchjs Nightwatch Cucumber Runner Config
| Knowledge Sources | |
|---|---|
| Domains | Testing, BDD, Configuration |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Configuration pattern for activating the Cucumber test runner in Nightwatch.js with feature paths and execution options.
Description
The Cucumber runner configuration sets test_runner.type to cucumber and provides options including feature_path for .feature file discovery. The src_folders array points to step definition directories. Additional settings control parallel execution, auto-session management, and custom commands paths.
Usage
Create a nightwatch configuration file (or section) with test_runner type set to 'cucumber'. Specify paths to feature files and step definitions.
Code Reference
Source Location
- Repository: nightwatch
- File: test/extra/cucumber-config.js (lines 1-44)
- File: test/extra/cucumber-config-parallel.js (lines 1-44)
- File: examples/cucumber-js/README.md (lines 13-34)
Signature
module.exports = {
test_runner: {
type: 'cucumber',
options: {
feature_path: string, // Glob path to .feature files
auto_start_session: boolean, // Auto-start WebDriver (default: true)
parallel: number // Number of worker threads
}
},
src_folders: string[], // Step definition directories
custom_commands_path: string[] // Optional custom commands
};
Import
// Configuration file - loaded via --config flag or default location
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| test_runner.type | string | Yes | Must be 'cucumber' to activate Cucumber runner |
| test_runner.options.feature_path | string | Yes | Glob path to .feature files |
| test_runner.options.auto_start_session | boolean | No | Auto-create WebDriver session (default: true) |
| test_runner.options.parallel | number | No | Number of parallel workers |
| src_folders | string[] | Yes | Paths to step definition files |
Outputs
| Name | Type | Description |
|---|---|---|
| Configured Cucumber runner | Configuration | Nightwatch uses Cucumber instead of default runner |
Usage Examples
Basic Cucumber Configuration
const path = require('path');
module.exports = {
test_runner: {
type: 'cucumber',
options: {
feature_path: path.join(__dirname, '../features/**/*.feature')
}
},
src_folders: ['features/step_definitions'],
webdriver: {
start_process: true
},
test_settings: {
default: {
desiredCapabilities: {
browserName: 'chrome'
}
}
}
};
Parallel Cucumber Configuration
const path = require('path');
module.exports = {
test_runner: {
type: 'cucumber',
options: {
feature_path: path.join(__dirname, '../features/**/*.feature'),
parallel: 4 // Run with 4 worker threads
}
},
src_folders: ['features/step_definitions']
};