How 7etrahedral/nightwatch-poc works
This repository is a NightwatchJS-based browser automation framework, not an application under test. Its architecture is organized around BDD feature files, page objects, step definitions, and a Dockerized Selenium/Chrome execution layer.
1. Test specification layer
- The top-level test intent lives in tests/features/*.feature.
- There are two feature areas: facebook_pages_check.feature and twitter_pages_check.feature.
- These files define human-readable scenarios and act as the entry point for the test flow.
2. BDD glue layer
- tests/step_definitions/** binds the Gherkin scenarios to executable automation steps.
- Step definitions are split by domain (facebook, twitter), which keeps feature logic separated from browser interaction details.
- This layer translates scenario steps into calls on page objects.
3. Page object layer
- tests/page-objects/** contains the browser interaction model.
- Facebook has multiple page objects: facebook_login_page.js, facebook_home_page.js, facebook_user_page.js, and facebook_create_pages_page.js.
- Twitter currently has a simpler set with twitter_home_page.js.
- This is the main abstraction boundary between test intent and UI selectors/actions.
4. Execution flow
- The runtime path is: feature file → step definition → page object → Nightwatch browser command.
- That keeps scenario logic stable even if selectors or navigation details change.
- The repository’s structure suggests tests are driven through Nightwatch’s BDD support.
5. Browser automation runtime
- package.json (not shown, but implied) and the README indicate NightwatchJS is the core test runner.
- Gruntfile.js likely orchestrates test-related tasks or command aliases.
- docker-chrome-conf.js appears to provide Nightwatch/Chrome execution settings for containerized runs.
6. Selenium infrastructure
- The selenoid/ directory contains the browser execution environment.
- selenoid/docker-compose.yml starts the Selenium-compatible infrastructure in Docker.
- selenoid/browsers.json defines browser image/runtime configuration, which is a key infra boundary for Chrome execution.
- This means tests are not expected to run against a local interactive browser by default; they are designed for remote containerized Chrome.
7. Configuration and environment
- env.sample is the template for local environment variables, copied to .env before running.
- This implies credentials and runtime settings are externalized rather than hardcoded.
- The architecture likely depends on environment-driven configuration for test targets, credentials, and Selenium endpoint details.
8. Reporting pipeline
- reports/chrome/create-html-report-chrome.js indicates a post-test HTML report generation step.
- The reports/chrome/ directory is the output/reporting boundary for test artifacts.
- The README’s separate npm run report-chrome step suggests report generation is decoupled from test execution.
9. Project organization by domain
- The test code is split by product area rather than by technical layer alone.
- Facebook is modeled more deeply than Twitter, which suggests different scenario complexity or coverage depth.
- This makes the repo easy to expand with additional feature domains while preserving the same BDD/page-object pattern.
10. Tooling and quality controls
- .eslintrc.js provides JavaScript linting.
- .vscode/ suggests local editor support and team workflow consistency.
- package-lock.json and npm ci in the README show dependency reproducibility is important.
11. How the system is intended to run
- Setup: copy env.sample to .env, install dependencies, bring up Selenoid via Docker Compose, run the tests, then generate the HTML report.
- The architecture is therefore a pipeline: configuration → remote browser grid startup → BDD test execution → reporting.
12. Diagram boundaries to preserve
- Draw clear boundaries between:
- Gherkin specs
- step definitions
- page objects
- Nightwatch runtime
- Selenoid/Docker browser infrastructure
- report generation
- The important external dependency is the browser grid, not a backend API or application server inside this repo.
Main entry points: facebook_login_steps.js Facebook steps · docker-chrome-conf.js Chrome config · twitter_steps.js Twitter steps · facebook_login_page.js Login page
Components 17
BDD specs
Gherkin feature files that define test intent.
- Facebook feature · Facebook browser automation scenarios.
tests/features/facebook_pages_check.feature - Twitter feature · Twitter browser automation scenarios.
tests/features/twitter_pages_check.feature
Step glue
Step definitions that bind scenarios to browser actions.
- Facebook steps · Step definitions for Facebook scenarios.
tests/step_definitions/facebook/facebook_login_steps.js - Twitter steps · Step definitions for Twitter scenarios.
tests/step_definitions/twitter/twitter_steps.js
Page objects
Browser interaction abstractions used by steps.
- Login page · Facebook login interactions.
tests/page-objects/facebook/facebook_login_page.js - Home page · Facebook home interactions.
tests/page-objects/facebook/facebook_home_page.js - User page · Facebook user/profile interactions.
tests/page-objects/facebook/facebook_user_page.js - Create pages · Facebook page creation interactions.
tests/page-objects/facebook/facebook_create_pages_page.js - Twitter home · Twitter home interactions.
tests/page-objects/twitter/twitter_home_page.js
Test runtime
Nightwatch execution and local test orchestration.
- Nightwatch · BDD-capable browser automation runtime.
- Grunt tasks · Command orchestration and aliases for test workflows.
Gruntfile.js - Chrome config · Nightwatch/Chrome execution settings.
docker-chrome-conf.js
Browser infra
Dockerized Selenium/Chrome execution environment.
- Compose stack · Starts the Selenium-compatible browser infrastructure.
selenoid/docker-compose.yml - Browsers config · Browser image/runtime definitions for the grid.
selenoid/browsers.json
Reporting
Post-test report generation and artifacts.
- HTML report · Creates the Chrome HTML test report.
reports/chrome/create-html-report-chrome.js
Tooling
Developer workflow and lint/config support.
- Env sample · Template for runtime variables and credentials.
env.sample - ESLint · JavaScript linting rules.
.eslintrc.js
Connections 19
- Facebook feature → Facebook steps: drives · Facebook scenarios are bound to step definitions.
- Twitter feature → Twitter steps: drives · Twitter scenarios are bound to step definitions.
- Facebook steps → Login page: uses · Facebook steps call into login interactions.
- Facebook steps → Home page: uses · Facebook steps call into home interactions.
- Facebook steps → User page: uses · Facebook steps call into user/profile interactions.
- Facebook steps → Create pages: uses · Facebook steps call into page creation interactions.
- Twitter steps → Twitter home: uses · Twitter steps call into home interactions.
- Login page → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Home page → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- User page → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Create pages → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Twitter home → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Nightwatch → Chrome config: configured by · Runner settings define Chrome execution behavior.
- Grunt tasks → Nightwatch: orchestrates · Task runner can launch test workflows.
- Chrome config → Compose stack: targets · Runner configuration points at remote browser infrastructure.
- Compose stack → Browsers config: loads · Compose stack uses browser runtime definitions.
- HTML report → Nightwatch: post-processes · Report generation consumes test output.
- Env sample → Chrome config: feeds · Environment variables supply runtime configuration.
- ESLint → Grunt tasks: supports · Linting supports the JavaScript workflow.