Nightwatch.js Tutorial Home / Video /

How To Install & Set Up Nightwatch.js For E2E Testing | Nightwatch.js Tutorial

How To Install & Set Up Nightwatch.js For E2E Testing | Nightwatch.js Tutorial

About The Video

In the second session of our Nightwatch.js tutorial series, π“πšπ©πšπ¬ π€ππ‘π’π€πšπ«π² demonstrates how to install and set up Nightwatch.js to test across multiple browsers.

You'll learn how to configure multiple browsers for cross-browser testing, securely manage globals and environment variables to avoid exposing sensitive data, and understand the differences between single and parallel runs.

Additionally, Tapas explains the significance of test workers and how they can boost your test execution efficiency.

🎯 What You'll Learn:

βœ… Nightwatch.js installation and setup

βœ… Configuration file deep dive (nightwatch.conf.js)

βœ… Multi-browser testing setup (Chrome, Safari, Firefox, Edge)

βœ… Environment variables & secrets management

βœ… Global variables configuration

βœ… Single vs Parallel test execution

βœ… Test workers' configuration

βœ… Page Object Model setup

By the end of this session, you’ll be able to set up Nightwatch.js effectively, ensuring a smooth testing experience across different environments.

Video Chapters

00:00 Introduction

01:34 Prerequisites

03:15 Installing Nightwatch

08:00 Understanding Nightwatch Scaffolding

10:50 Nightwatch Configuration

13:59 Running a Test

15:22 Running Tests on Multiple Browsers

17:04 Single vs Parallel Test Execution

18:54 Using Globals

21:30 Environment Variables

24:22 Conclusion & Next Steps

Key Topics Covered

In this second episode of the NightwatchJS series, the instructor guides viewers through the complete setup and configuration of NightwatchJS for a project. The session begins with installing NightwatchJS using NodeJS and npm, highlighting prerequisites like NodeJS, a code editor (e.g., VS Code), a web browser, and optionally a terminal.

The installation process is explained step by step, covering both new and existing projects, and guiding users through initial configuration options such as project purpose, language (JavaScript or TypeScript), and target browsers. The instructor emphasizes best practices, including separating test files from source code to maintain modularity and simplify CI/CD integration.

Once installed, the video dives into the folder structure created by NightwatchJS, including folders for custom assertions, custom commands, examples, page objects (POM), templates, and the test folder. Each folder’s purpose is explained: custom assertions for project-specific conditions, custom commands for reusable actions, examples for reference, POM for maintaining clean, modular test code, and templates for creating standard test structures.

The importance of the nightwatch.conf.js configuration file is highlighted, detailing paths for tests, page objects, custom commands, and assertions, as well as global variables, plugin support, and test worker settings for single versus parallel runs. The instructor demonstrates configuring browser capabilities, starting with Chrome and Edge, and explains how to add Safari and Firefox.

Key Mac-specific instructions are provided for running tests on Safari, including enabling remote automation in developer settings. The video also covers running tests in parallel using test workers, allowing simultaneous execution across multiple browsers.

The session introduces globals for sharing values across test suites, showing how to define them directly in the configuration file or through a separate global file. Examples include a global team variable accessible via browser.globals.

The tutorial then covers environment variables for storing sensitive information, such as LambdaTest username and access keys, demonstrating how to access these variables both in configuration files and within test scripts using process.env.

Throughout the session, the instructor runs multiple example tests to illustrate configuration changes, browser selection, parallel execution, and access to globals and environment variables.

Related Hubs

Nightwatch.js Tutorial For Test Automation–Complete Guide With Examples

More Videos from Nightwatch.js Tutorial