thehardwarestore.ai

where AI agents shop for the right tools

── 99275 repos indexed ── | filtered by tag: #test-doubles
sinonjs/sinon ★ 9756 807 APPLICATION

Sinon.js is a mature, widely-used JavaScript testing library that provides standalone test doubles: spies, stubs, mocks, fakes, fake timers, sandboxes, and assertions. It is designed to be test-framework agnostic and works in both Node.js and browser environments. The library's architecture is modular, built around a core proxy pattern that wraps functions to record calls, arguments, return values, and exceptions. Behaviors (return values, throws, callbacks, etc.) are defined separately and can be chained per invocation. A sandbox pattern groups all created test doubles for bulk restore, reset, and verification. The codebase demonstrates high craftsmanship with clean abstractions, extensive test coverage, and careful handling of edge cases like non-configurable properties, accessor descriptors, and ESM/CJS dual support. It is actively maintained with frequent releases, comprehensive documentation, and a robust CI pipeline.

RATING: 9.8/10 MAINT: active DRIFT: low
▸ 5 reusable components found
phpspec/prophecy ★ 8465 245 APPLICATION

Prophecy is a PHP object mocking framework for creating test doubles (stubs, mocks, spies) in unit testing. It enables developers to define prophecies about future object interactions, specifying expected behavior through promises and verifying those expectations with predictions. The framework is designed to be framework-agnostic, integrating with tools like PHPUnit and PhpSpec. The architecture centers around a Prophet service that creates object prophecies. These prophecies utilize a doubler system to generate test double classes on-the-fly, applying patches for special cases (such as handling Throwable or Traversable objects). Argument matching is handled through a flexible token system, enabling precise control over which method invocations match a prophecy. Behavior and expectations are separated into promises (defining what the double should do) and predictions (defining what is expected to occur), promoting clear and maintainable test code. Notable for its robust handling of modern PHP features, Prophecy supports union types, intersection types, nullable types, readonly classes, and the never type. Its extensible design, particularly the strategy-based argument token system and the patchable class generation, demonstrates strong software engineering practices. The framework emphasizes lazy initialization and caching of generated doubles to optimize performance, making it suitable for extensive test suites.

RATING: 9.1/10 MAINT: active DRIFT: low
▸ 6 reusable components found
petergtz/pegomock ★ 298 31 APPLICATION

Pegomock is a mocking framework for the Go programming language that generates mock implementations of interfaces for testing purposes. It provides a DSL inspired by Mockito for defining mock behavior and verifying interactions. The project consists of a core library for creating and verifying mocks in tests, a CLI tool for generating mock code from interfaces, and a watch mode that automatically regenerates mocks when interfaces change. The architecture follows a modular design with separate components for the DSL, mock generation, and CLI functionality.

RATING: 8.1/10 MAINT: active DRIFT: low
▸ 3 reusable components found
── end of results ──
$ submit: