Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Nightwatchjs Nightwatch Extension Path Settings

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

Overview

Configuration settings for specifying custom command and assertion directory paths in Nightwatch.js.

Description

The custom_commands_path and custom_assertions_path settings in nightwatch.conf.js accept a string or array of strings pointing to directories containing custom extension modules. Nightwatch auto-loads all files from these directories at startup and registers them on browser (commands) and browser.assert/browser.verify (assertions).

Usage

Set these paths in nightwatch.conf.js before using any custom commands or assertions in tests.

Code Reference

Source Location

  • Repository: nightwatch
  • File: test/extra/cucumber-config.js (line 16)

Signature

module.exports = {
  custom_commands_path: string | string[],
  custom_assertions_path: string | string[]
};

Import

// Configuration setting - no import required

I/O Contract

Inputs

Name Type Required Description
custom_commands_path string or string[] No Path(s) to directories containing custom command files
custom_assertions_path string or string[] No Path(s) to directories containing custom assertion files

Outputs

Name Type Description
Registered commands Functions Custom commands available on browser.commandName()
Registered assertions Functions Custom assertions available on browser.assert.assertionName()
Namespaced commands Functions Subdirectory commands on browser.namespace.commandName()

Usage Examples

Configuration with Extension Paths

const path = require('path');

module.exports = {
  custom_commands_path: [
    path.join(__dirname, './custom-commands')
  ],

  custom_assertions_path: [
    path.join(__dirname, './custom-assertions')
  ],

  // Multiple paths
  // custom_commands_path: ['./commands', './more-commands'],

  webdriver: {
    start_process: true
  }
};

Related Pages

Implements Principle

Page Connections

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