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.

Principle:Nightwatchjs Nightwatch Module Import

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

Overview

A module loading pattern for importing a testing framework's programmatic API and named exports for use outside the standard test runner context.

Description

Module Import provides access to the full programmatic API of a testing framework from any Node.js script. This enables integration with CI/CD pipelines, custom orchestration tools, and test management systems. Rather than relying solely on CLI execution, the programmatic API allows tests to be launched, configured, and controlled from code.

Named exports provide direct access to specific API namespaces (browser, element, assert, expect, etc.) for use in global scope or custom wrappers.

Usage

Import the module when you need programmatic control over test execution, such as in CI/CD scripts, custom test orchestrators, or when embedding test functionality in a larger application.

Theoretical Basis

The module export pattern follows Node.js conventions:

  1. Default export: The main module object with factory methods
  2. Named exports: Individual API namespaces (browser, assert, element, etc.)
  3. Re-exports: Third-party utilities (selenium-webdriver's By, Key, Capabilities)

Related Pages

Implemented By

Uses Heuristic

Page Connections

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