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.

Principle:Nightwatchjs Nightwatch Session Cleanup

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

Overview

A resource cleanup pattern that terminates browser sessions, empties command queues, and frees allocated resources after test execution completes.

Description

Session Cleanup ensures that all resources allocated during test execution are properly released. This includes terminating the WebDriver session (closing the browser), emptying the command queue, resetting the logger, and removing event listeners. Proper cleanup prevents resource leaks in long-running processes and is essential in programmatic usage where multiple test cycles may run in a single Node.js process.

Usage

Always call cleanup methods after test execution completes, especially in programmatic usage where the process continues after tests finish.

Theoretical Basis

Cleanup follows a two-level resource release pattern:

  1. Browser level: end() or quit() terminates the WebDriver session
  2. Client level: cleanup() empties queues, resets loggers, removes listeners
  3. Both levels must be called for complete cleanup

Related Pages

Implemented By

Page Connections

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