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.

Implementation:SeleniumHQ Selenium Closure Testing Mock

From Leeroopedia
Knowledge Sources
Domains JavaScript_Atoms, Vendored_Library
Last Updated 2026-02-12 00:00 GMT

Overview

Vendored Google Closure Library module providing mock object base classes used by Selenium JavaScript atoms.

Description

goog.testing.Mock is a vendored copy of the Google Closure Library module. It defines base classes for creating mock objects in JavaScript, inspired by the EasyMock API. The workflow involves creating a mock, setting expectations on method calls (including minimum/maximum call counts and return values), calling $replay() to switch to verification mode, and then $verify() to confirm expectations were met. It supports both strict and loose mock variants. Selenium uses this as part of its JavaScript atom infrastructure.

Usage

This module is consumed internally by Selenium's JavaScript atoms build system. Not imported directly by end users.

Code Reference

Source Location

Key Exports

goog.provide('goog.testing.Mock');
goog.provide('goog.testing.MockExpectation');

// MockExpectation - represents expected method calls
goog.testing.MockExpectation = function(name) { ... };
goog.testing.MockExpectation.prototype.minCalls = 1;
goog.testing.MockExpectation.prototype.maxCalls = 1;

// Mock - base class for mock objects
// API: $replay(), $verify(), $reset()

Related Pages

Page Connections

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