How nightwatchjs/nightwatch works
Nightwatch is a Node.js test-automation framework: a test author runs suites through its CLI or programmatic API, test-runner integrations execute cases and hooks, and the Nightwatch client sends browser or mobile commands through WebDriver/Appium transports. Results, assertions, screenshots and reports support the feedback loop. The README also documents component, visual-regression, accessibility and API testing capabilities; corresponding visible API, screenshot and axe modules are included, while API-test wiring is not inferred from the sampled HTTP transport. Source excerpts are partial, so some subsystem links are omitted.
Main entry points: factory.js Transport factory · api/index.js API loading · testsuite/index.js Suite lifecycle · runner.js Suite runner
Components 24
Test execution
- CLI entry
lib/runner/cli/cli.js - Suite runner
lib/runner/runner.js - Test integrations
lib/runner/test-runners - Suite lifecycle
lib/testsuite/index.js - Configuration
lib/settings/settings.js
Automation API
- Nightwatch client
lib/core/client.js - API loading
lib/api/index.js - Browser commands
lib/api/client-commands - Element commands
lib/api/element-commands - Web elements
lib/api/web-element - Assertions
lib/api/assertions - Expect API
lib/api/expect - Page objects
lib/page-object/index.js
Device connectivity
- Transport factory
lib/transport/factory.js - WebDriver transport
lib/transport/selenium-webdriver/index.js - HTTP requests
lib/http/request.js - Appium support
lib/transport/selenium-webdriver/appium.js
Results and feedback
- Reporter
lib/reporter/index.js - Test results
lib/reporter/results.js - Visual capture
lib/utils/screenshots.js - Accessibility checks
lib/api/client-commands/axeRun.js
Other components
- Test author
- Browser or device
- WebDriver endpoint
Connections 32
- Test author → CLI entry: starts tests
- Test author → Suite lifecycle: defines cases
- CLI entry → Suite runner: starts runner
- Suite runner → Configuration: loads settings
- Suite runner → Test integrations: selects runner
- Suite runner → Suite lifecycle: runs suites
- Test integrations → Suite lifecycle: executes cases
- Suite lifecycle → Nightwatch client: creates client
- Nightwatch client → Configuration: uses settings
- Nightwatch client → API loading: loads APIs
- API loading → Browser commands: registers commands
- API loading → Element commands: registers commands
- API loading → Assertions: registers assertions
- API loading → Expect API: registers expect
- API loading → Page objects: loads objects
- Element commands → Web elements: builds element API
- Suite lifecycle → Reporter: records outcomes
- Nightwatch client → Transport factory: creates transport
- Transport factory → WebDriver transport: selects driver
- Transport factory → Appium support: selects mobile
- Browser commands → Transport factory: dispatches commands
- Element commands → Transport factory: dispatches commands
- Assertions → Transport factory: checks browser state
- Expect API → Transport factory: checks browser state
- WebDriver transport → HTTP requests: sends requests
- HTTP requests → WebDriver endpoint: WebDriver protocol
- WebDriver endpoint → Browser or device: controls session
- Appium support → WebDriver endpoint: controls device
- Reporter → Test results: updates results
- Suite lifecycle → Visual capture: captures on error
- Browser commands → Accessibility checks: runs accessibility
- Reporter → Test author: reports outcomes