Principle:Nightwatchjs Nightwatch Module Import
| 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:
- Default export: The main module object with factory methods
- Named exports: Individual API namespaces (browser, assert, element, etc.)
- Re-exports: Third-party utilities (selenium-webdriver's By, Key, Capabilities)