Nightwatch DevTools
Nightwatch adapter for WebdriverIO DevTools - brings the same visual debugging UI to your Nightwatch test suite with zero test code changes.
Installation
npm install @wdio/nightwatch-devtools
Setup
Standard Nightwatch (mocha-style)
// nightwatch.conf.cjs
const nightwatchDevtools = require('@wdio/nightwatch-devtools').default
module.exports = {
src_folders: ['tests'],
test_settings: {
default: {
desiredCapabilities: {
browserName: 'chrome',
// Required for network request capture
'goog:loggingPrefs': { performance: 'ALL' }
},
globals: nightwatchDevtools({ port: 3000 })
}
}
}
Run your tests as normal - the DevTools UI opens automatically in a new browser window:
nightwatch
No changes to your test files are needed.
Cucumber / BDD
Import cucumberHooksPath alongside the main export and pass it to the Cucumber require option. This registers Before / After scenario hooks that mirror the WebdriverIO service's beforeScenario / afterScenario behaviour.
// nightwatch.conf.cjs
const nightwatchDevtools = require('@wdio/nightwatch-devtools').default
const { cucumberHooksPath } = require('@wdio/nightwatch-devtools')
module.exports = {
src_folders: ['features/step_definitions'],
test_runner: {
type: 'cucumber',
options: {
feature_path: 'features',
require: [cucumberHooksPath] // <-- register DevTools Cucumber hooks
}
},
test_settings: {
default: {
desiredCapabilities: {
browserName: 'chrome',
'goog:loggingPrefs': { performance: 'ALL' }
},
globals: nightwatchDevtools({ port: 3000 })
}
}
}
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
port | number | 3000 | Port for the DevTools backend server. Auto-incremented if already in use. |
hostname | string | 'localhost' | Hostname the backend server binds to. |
screencast | ScreencastOptions | { enabled: false } | Per-session .webm video recording. See Screencast below. |
bidi | boolean | false | Opt into WebDriver BiDi capture for browser console + JS exceptions + network. Requires webSocketUrl: true in your capabilities and a BiDi-capable chromedriver. When attached, the per-command Chrome perf-log network path is gated off so requests don't duplicate. |
mode | 'live' | 'trace' | 'live' | live opens the DevTools UI; trace skips it and writes a portable artifact instead. See Trace Mode. |
traceFormat | 'zip' | 'ndjson-directory' | 'zip' | Trace artifact layout. Only applies when mode: 'trace'. |
globals: nightwatchDevtools({
port: 3000,
hostname: 'localhost',
screencast: { enabled: true },
bidi: true
})
Screencast
Record a continuous .webm video of the browser session. The recording starts on the first session the plugin sees and is finalized in Nightwatch's after() hook.
Polling mode only. Nightwatch doesn't expose a stable CDP escape hatch the way WebdriverIO (browser.getPuppeteer()) and Selenium (driver.createCDPConnection) do, so the screencast captures frames by calling browser.takeScreenshot() at a fixed interval. Works on every browser Nightwatch supports.
globals: nightwatchDevtools({
port: 3000,
screencast: { enabled: true, pollIntervalMs: 200 }
})
| Option | Type | Default | Notes |
|---|---|---|---|
enabled | boolean | false | Master switch. |
pollIntervalMs | number | 200 | Screenshot interval (ms). Lower = smoother video, more WebDriver round-trips. 200 ms ≈ 5 fps. |
captureFormat | 'jpeg' | 'png' | 'jpeg' | Per-frame pixel format handed to the ffmpeg encoder before the final .webm mux. In polling mode the source screenshots are always captured as PNG, so this does not change the capture - only the format the encoder receives per frame. |
maxWidth / maxHeight / quality | - | - | CDP-only options, ignored in polling mode. Listed for shape compatibility with the WDIO/Selenium adapters. |
Prerequisites: fluent-ffmpeg (already a runtime dep of the package) plus the ffmpeg binary on PATH. macOS: brew install ffmpeg. Linux: apt install ffmpeg. Without ffmpeg the recorder still runs but the encode step logs a warning and skips writing the file.
Output: the video file is written next to the test file that just ran (with nightwatch.conf.* directory as a fallback, then process.cwd() as a last resort). The full path appears in the Nightwatch log line 📹 Screencast video: <path> and the video is also streamed to the dashboard's Screencast tab.
For the full screencast feature reference (browser support, output paths across all three adapters), see the Screencast page.