Text of patch.hexdocs.pm › changelog.html as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Change Log — patch v0.16.1

View Source Change Log 0.16.1 (2026-10-22) Bugfix inspired by Deven Wen who reported a bug where patch would incorrectly handle callable stacks in OTP 28+. Bugfixes 🐞 - Fixed a bug when partially patching function clauses in OTP 28+ 0.16.0 (2025-06-03) No new functionality in this release but an update to the CI/CD versions and bugfix. Patch should continue to work on older versions of Elixir but CI/CD runner versions have been updated to re-enable CI/CD.

Thanks to Steve Cohen who reported a bug where patch would incorrectly handle multiple export attributes. This bug has been fixed and a test added. Bugfixes 🐞 - Fixed a bug in handling multiple exports for the same function with different arities. Breaking Changes 💔 - Elixir 1.9 and Elixir 1.10 are no longer part of the CI/CD matrix. 0.15.0 (2024-12-27) No new functionality in this release but an update to the supported versions.

Thanks to Moosieus Patch now compiles cleanly on Elixir 1.9+ with the removal of some outdated language constructs in favor of more modern constructs. 0.15.0 removes support for Elixir 1.7 (released in July of 2018) and 1.8 (released in January of 2019). This version also adds 1.17 and 1.18 to the support matrix. If you are still running on 1.7 or 1.8 you should continue to use the 0.14.0 release, if you require ongoing support you should open an issue to discuss.

Improvements ⬆️ - [Versions] Elixir 1.17 and 1.18 are now supported and part of CI. Breaking Changes 💔 - Elixir 1.7 and Elixir 1.8 are no longer supported. 0.14.0 (2024-10-15) Changes where mocks are evaluated to prevent misuse and allow for common patterns that were not previously supported. Pre-0.14.0 mocks would be intercepted by the Patch.Mock.Server and the mock value would be calculated by the server. This works for most cases, but has surprising behavior when the mock function cares about the process executing the function.

Consider the following example. defmodule ExampleTest do use ExUnit.Case use Patch test "example" do patch ( Example , :get_pid , fn -> self ( ) end ) assert Example . get_pid ( ) == self ( ) end end This would fail in pre-0.14.0 because the fn -> self() end would be executed by the Patch.Mock.Server and the pid returned would be the pid for the Patch.Mock.Server and not the caller's pid as the test author might expect.

0.14.0 changes this behavior and now will execute the fn -> self() end in the caller and return the expected result. This also makes it much more difficult to address the Patch.Mock.Server directly, which is generally discouraged as this server is an implementation detail and should only be addressed by the Patch code itself. This should prevent a class of errors and confusing bugs caused by tests accidentally capturing the pid of, monitoring, or linking to the Patch.Mock.Server Improvements ⬆️ - [Internal] Mocks are now evaluated in the caller process instead of the Patch.Mock.Server process, see above for details.

Breaking Changes 💔 - Mocks are now evaluated in the caller process instead of the Patch.Mock.Server process. Using the Patch.Mock.Server pid or interacting with the process is not advised but if your tests relied on being able to do this they may break due to this change. 0.13.1 (2024-05-02) Minor bugfix to correct an issue with negative step ranges in String.slice/2 raised by Josephine Hissssst Luca Corti Bugfixes 🐞 - Fixed a warning raised from using a range with a negative step in String.slice/2 0.13.0 (2023-10-17) Added the ability to control how Patch functions are imported in test modules.

Added the ability to listen/3 without a target, useful when a process is spawned by another process and the spawning of that process is not within the testing boundaries. Features 🎁 - listen/1 can now be used to construct a listener without a target. 🎁 - inject/4 can now be used to inject a listener without a target. 🎁 - use Patch now accepts :alias , :only , and :except to control exactly which Patch helpers are being pulled in and how they will be named.

Breaking Changes None 0.12.0 (2022-02-08) Fixed a bug where defective mock functions would be incorrectly classified as unmocked functions, this would engage the passthrough functionality and call the original function. If a passthrough mock function's implementation raised BadArityError or FunctionClauseError it would be incorrectly classified by the mock system as an unmocked function. The internal mechanisms have been updated to differentiate between exceptions arising directly from the function call vs exceptions in caused by executing the code in the function.

Added a new debug/0,1 facility that can be used to enable library level debugging in for a test function. This functionality can also be controlled by the :patch :debug configuration value. Features 🎁 - debug/0,1 has been added. By default it will enable debugging for the test it is invoked in. If debugging has been enabled suite wide via the :patch :debug configuration value, then debug/1 can be used with the argument false to disable testing for the test it is invoked in.

Bugfixes 🐞 - Fixed the issue where defective mocks would cause the mock system to call the original function. Improvements ⬆️ - [CI] Updated CI tests from 1.12.2 to 1.12.3 and added 1.13.2 tests to the compatibility matrix. Breaking Changes None 0.11.0 (2022-01-21) New private/2 macro to assist with using exposed functions. Introduces "Tagged Histories" to prevent a race condition that causes confusing output when using Patch assertions.

Race Condition Description: Assertion function checks the history for a matching call, none is found. Assertion function pulls the history to format an error message. Between 1 and 2 if a matching call arrived then the assertion would fail but print out a message with a matching call. This race condition has been defeated by only pulling the history once and using it for both checking for the existence of a call and formatting an error message.

In addition a bunch of code that was littering Patch.Mock has been moved to a more appropriate location by introducing the concept of a "Tagged History" (Patch.Mock.History.Tagged) Tagged Histories have the same entries as a History. One generates a Tagged History from a History and some matching criteria. Ever entry in the Tagged History is the entry from the History tagged with a boolean that indicates whether or not it matched the construction criteria.

Features 🎁 - private/2 has been added, it's similar to private/1 but allows the test author to pipe a value into private/2 and have it end up in the call that's being wrapped. Bugfixes 🐞 - Fixed the behavior of Patch Assertion functions to prevent the race condition described above. Breaking Changes None 0.10.2 (2022-01-20) Major fix to Patch.Mock.Code.Transforms.Remote . Previously this transform completely ignored remote calls.

This would cause an issue when one of the arguments to the remote call was itself a local call. This has been corrected and the Patch.Test.User.Patch.LocalCallTest was updated to prevent regressions. Bugfixes 🐞 - Fixed the Patch.Mock.Code.Transforms.Remote transformer to correctly handle the arguments of a Remote Call. 0.10.1 (2021-12-07) Minor fix to .formatter.exs . Exported format options were not being honored because of a typo, export is the honored key but exports was being used.

Improvements ⬆️ - [Change Log] Removed sections that have no content, except for Breaking Changes . Sections will only be included in the Change Log if some change has actually occurred. To aid developers upgrading where between versions where breaking changes are allowed, Breaking Changes will be included when there are no breaking changes with the description None to clearly indicate that no breaking changes have occurred.

Bugfixes 🐞 - Fixed the .formatter.exs so assertion functions won't be parenthesized by projects using import_deps 0.10.0 (2021-12-05) Changes how function patches work by

The rest of this page is on the live site.