Implementation:SeleniumHQ Selenium Closure Testing Mock
| 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
- Repository: SeleniumHQ_Selenium
- File: third_party/closure/goog/testing/mock.js
- Lines: 1-767
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()