Implementation:SeleniumHQ Selenium Closure Testing PropertyReplacer
| Knowledge Sources | |
|---|---|
| Domains | JavaScript_Atoms, Vendored_Library |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Vendored Google Closure Library module providing a helper for stubbing out variables and object properties in tests, used by Selenium JavaScript atoms.
Description
goog.testing.PropertyReplacer is a vendored copy of the Google Closure Library module. It provides a helper class for stubbing out variables and object properties during unit tests, similar to Python's StubOutForTesting. It tracks all property changes chronologically and can restore original values via reset() in tearDown. Supports replace() to swap function implementations and set() to override property values, with automatic tracking of whether a key existed before modification. 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/propertyreplacer.js
- Lines: 1-313
Key Exports
goog.provide('goog.testing.PropertyReplacer');
goog.testing.PropertyReplacer = function() { ... };
// Tracks original values: this.original_ = [];
goog.testing.PropertyReplacer.NO_SUCH_KEY_ = {};
// Key methods: set(obj, key, value), replace(obj, key, value), reset()