Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Nightwatchjs Nightwatch CreateClient Options

From Leeroopedia
Knowledge Sources
Domains Testing, API, Configuration
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete options object specification for Nightwatch.createClient() defining browser, execution, and environment settings.

Description

The options object passed to createClient() controls all aspects of the client: browser selection (browserName), headless mode, output verbosity (silent, output), async command mode (useAsync), global variables, dev tools, debugging, and the config file path. The options are merged with defaults from the configuration file.

Usage

Construct an options object and pass it to Nightwatch.createClient(). Only specify settings that differ from defaults.

Code Reference

Source Location

  • Repository: nightwatch
  • File: lib/index.js (lines 16-51)

Signature

Nightwatch.createClient({
  headless: Boolean,              // default: false - Run in headless mode
  silent: Boolean,                // default: true - Suppress output
  output: Boolean,                // default: true - Enable output
  useAsync: Boolean,              // default: true - Async command mode
  env: String,                    // default: null - Test environment name
  timeout: Number,                // default: null - Global timeout
  parallel: Boolean,              // default: false - Parallel mode
  reporter: Object,               // default: null - Custom reporter
  browserName: String,            // default: null - 'chrome'|'firefox'|'safari'|'edge'
  globals: Object,                // default: {} - Global variables
  devtools: Boolean,              // default: false - Enable DevTools
  debug: Boolean,                 // default: false - Enable debug mode
  enable_global_apis: Boolean,    // default: false - Enable global browser/element
  config: String,                 // default: './nightwatch.json' - Config file path
  disable_process_listener: Boolean, // default: false
  test_settings: Object           // Additional settings to merge
}) -> ClientWrapper

Import

const Nightwatch = require('nightwatch');

I/O Contract

Inputs

Name Type Required Description
headless Boolean No Run browser in headless mode (default: false)
browserName String No Browser name: 'chrome', 'firefox', 'safari', 'edge'
env String No Test environment name from configuration
config String No Path to configuration file (default: './nightwatch.json')
useAsync Boolean No Enable async command mode (default: true)
enable_global_apis Boolean No Enable global browser/element (default: false)
globals Object No Global variables passed to tests
timeout Number No Global timeout in milliseconds

Outputs

Name Type Description
ClientWrapper Object Wrapper with launchBrowser(), updateCapabilities(), settings, cleanup()

Usage Examples

Create Client with Options

const Nightwatch = require('nightwatch');

const client = Nightwatch.createClient({
  browserName: 'chrome',
  headless: true,
  silent: false,
  output: true,
  enable_global_apis: true,
  globals: {
    baseUrl: 'https://staging.example.com'
  }
});

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment