Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Nightwatchjs Nightwatch Session Cleanup

From Leeroopedia
Revision as of 17:40, 16 February 2026 by Admin (talk | contribs) (Auto-imported from principles/Nightwatchjs_Nightwatch_Session_Cleanup.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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