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.

Implementation:Nightwatchjs Nightwatch Nightwatch CLI Init

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

Overview

External CLI scaffolding tool for initializing a new Nightwatch.js project with configuration, directories, and dependencies.

Description

The npm init nightwatch@latest command invokes the create-nightwatch package, an interactive CLI wizard that generates a complete Nightwatch.js project scaffold. This is an external npm initializer package (not part of the nightwatch repository itself). The generated project invokes bin/runner.js as its entry point for test execution.

Usage

Run this command once when setting up a new Nightwatch testing project or adding Nightwatch to an existing Node.js project. The wizard guides through browser selection, test runner choice, and directory configuration.

Code Reference

Source Location

  • Repository: nightwatch (entry point invoked by generated project)
  • File: bin/runner.js (lines 1-41)

Signature

npm init nightwatch@latest
# Interactive wizard prompts:
# - Browser selection (Chrome, Firefox, Safari, Edge)
# - Test runner (Mocha, Cucumber)
# - Base URL
# - Test folder location

Import

# No import required - this is a CLI command
npm init nightwatch@latest

I/O Contract

Inputs

Name Type Required Description
project directory Directory Yes Empty or existing Node.js project directory

Outputs

Name Type Description
nightwatch.conf.js File Nightwatch configuration with selected browsers and settings
test directory Directory Test folder structure (e.g., test/ or tests/)
package.json File Updated with nightwatch dependency and test scripts

Usage Examples

Initialize New Project

# Create a new directory and initialize
mkdir my-e2e-tests
cd my-e2e-tests
npm init nightwatch@latest

# Follow the interactive prompts, then run:
npx nightwatch

Add to Existing Project

# In an existing Node.js project
cd my-existing-app
npm init nightwatch@latest

# The wizard detects existing package.json and adapts

Related Pages

Implements Principle

Requires Environment

Page Connections

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