मुख्य सामग्री पर जाएं

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

OptionTypeDefaultDescription
portnumber3000Port for the DevTools backend server. Auto-incremented if already in use.
hostnamestring'localhost'Hostname the backend server binds to.
globals: nightwatchDevtools({
port: 3000,
hostname: 'localhost'
})

Examples

Working examples are included in the package:

DirectoryRunnerCommand
example/Nightwatch mocha-stylepnpm example

Build the package first:

# From repo root
pnpm build --filter @wdio/nightwatch-devtools
cd packages/nightwatch-devtools
pnpm example

Features

The Nightwatch adapter provides the same DevTools UI experience:

Limitations

Nightwatch does not provide the same depth of framework hooks as WebdriverIO, so there are a few differences from the WDIO DevTools service:

LimitationDetail
No native command hooksNightwatch has no beforeCommand / afterCommand hook. Commands are intercepted via a browser proxy wrapper instead.
Limited test contextbrowser.currentTest provides less metadata than the WDIO runner context; test names and file paths require additional heuristics.
Flat suite nestingNightwatch does not natively support multiply-nested describe blocks; the plugin reports a maximum of two levels.
Delayed result availabilityTest results are only finalised in afterEach, not available mid-test.

Overall feature parity with the WebdriverIO DevTools service is approximately 80–90%.

Welcome! How can I help?

WebdriverIO AI Copilot