All notable changes to this project will be documented in this file. See standard-version for commit guidelines.
9.2.2 (2026-04-29)
- deps: update dependency lodash to ~4.18.1 2106d3
9.2.1 (2026-04-17)
- deps: update dependency lodash to ~4.18.0 [security] (32331d6)
- deps: update jest monorepo to ~30.3.0 (b0122d6)
9.2.0 (2026-02-12)
- Allow mock name customization (73c3b1c)
- You can now name mocks with
mock<T>({ name: 'MyCustomMock' })to help identify them in error messages.
- You can now name mocks with
9.1.0 (2026-01-13)
Important
The next major version (v10) will be ESM-only. Since Node 20.19 supports require(esm) by default (see Node 20.19.0 release post), no changes should be required for CJS projects using Node 20.19 or higher.
- Publish ESM build, alongside CJS (f1ece16)
- This is in preparation for v10, which will be ESM-only. ESM projects should use the ESM build automatically, while CJS projects will continue to use the CJS build.
- Support nesting matchers in
deepEquals(the default matcher) (7c243d2)- Example:
when(() => mockedFn({ foo: It.isNumber() }))
- Example:
- Fix diff integration with IDEs for vitest (f881346)
9.0.1 (2024-11-23)
- deps: update dependency jest-diff to ~29.7.0 (50a3aa8)
- Pretty print nested matchers in
isArray(24f9deb)
9.0.0 (2024-05-27)
This version greatly improves error messages and the matcher API. Check the migration guide.
const fn = mock<(x: number, y: number, z: { foo: string }) => number>();
when(() => fn(1, 2, { foo: 'bar' })).thenReturn(42);
fn(1, 2, { foo: 'baz' });| Before | After |
|---|---|
![]() |
![]() |
isObjecthas been replaced byisPlainObjectandcontainsObject- Merge
isString's optionalcontainingandmatchingargs - Rename the
toJSONmatcher method totoString - Don't allow empty partials in
containsObject
- Attach actual/expected args to error instance to enable IDE diffs (7a04a43)
- Improve
isArraydiff (a5aaddd) - Improve
isNumberdiff (55647ed) - Improve
isObjectdiff (5533bcf) - Improve
isStringdiff (5c73fbb) - Improve
willCapturediff (7d92ce9) - Improve colors in UnexpectedCall error message (f326954)
- Pretty print argument diffs in UnexpectedCall error messages (ba4f6b5)
- Fix
isPartialallowing unexpected keys (cc0b881) - Fix
isPartialnot working with interfaces (169b336) isObjectnow correctly fails fornullandundefined(9b50fe4)- Fix
Itdocstrings (df7f91a) - Handle non string keys in
isObject(87cb768)
9.0.0-beta.3 (2024-05-23)
- Don't allow empty partials in
containsObject - Rename
isPartialtocontainsObject
- Don't allow empty partials in
containsObject(6c76608)
9.0.0-beta.2 (2024-05-22)
- Fix
isPartialnot working with interfaces (169b336)
9.0.0-beta.1 (2024-05-22)
isObjecthas been replaced byisPlainObjectandisPartial.
9.0.0-beta.0 (2023-09-24)
- Merge
isString's optionalcontainingandmatchingargs - Rename the
toJSONmatcher method totoString isObjectnow correctly fails fornullandundefined
- Attach actual/expected args to error instance to enable IDE diffs (7a04a43)
- Improve
isArraydiff (a5aaddd) - Improve
isNumberdiff (55647ed) - Improve
isObjectdiff (5533bcf) - Improve
isStringdiff (5c73fbb) - Improve
willCapturediff (7d92ce9) - Improve colors in UnexpectedCall error message (f326954)
- Pretty print argument diffs in UnexpectedCall error messages (ba4f6b5)
-
isObjectnow correctly fails fornullandundefined(9b50fe4) -
Fix
Itdocstrings (df7f91a) -
Handle non string keys in
isObject(87cb768) -
Merge
isString's optionalcontainingandmatchingargs (f53a05e) -
Rename the
toJSONmatcher method totoString(95ffd6b)
8.0.1 (2023-01-18)
- Allow mocks to be inside Promises (3144722), closes #321
- deps: update dependency jest-matcher-utils to ~29.3.0 (929d16e)
8.0.0 (2022-10-02)
This is a major release with many new features, some breaking changes, and a lot of changes under the hood. See the migration guide.
- You no longer have to remember to call
instancebefore passing the mock to the code under test, because we removed it! The object returned bymock()can now be passed directly to your code. - Expectations now have to be wrapped in a callback
inside
when. This change is necessary to remove theinstancefunction. - The default matcher option previously available only in
setDefaultshas been renamed toconcreteMatcher. - The default behavior now avoids immediately throwing
on unexpected property access. This should lead to improved error
messages, and less breaking on common code patterns e.g. destructuring. You can configure this with the
unexpectedPropertyoption. - You can no longer pass a custom expectation repository
or a custom expectation factory to the
mock()function. These options weren't documented very well and just bloated the API.
- Add
exactParamsoption (31acbbe) - Add
unexpectedPropertyoption - Allow concrete matcher to be configured for each mock (32c82ba)
- Don't treat
anyreturns as promises (9304492)
8.0.0-beta.2 (2022-09-26)
- The
strictnessoption has been renamed tounexpectedPropertyto better illustrate its intent.
- Add
exactParamsoption (31acbbe)
-
deps: update dependency jest-matcher-utils to v28 (33fe92a)
-
Don't treat
anyreturns as promises (9304492) -
Rename option (db9cc06)
8.0.0-beta.1 (2022-08-18)
- The default matcher option previously available only in
setDefaultshas been renamed toconcreteMatcher. - The default strictness now avoids immediately throwing on unexpected property access. This should lead to improved error messages, and less breaking on common code patterns e.g. destructuring.
If you want the old behavior use:
import { setDefaults, Strictness } from 'strong-mock';
setDefaults({ strictness: Strictness.SUPER_STRICT });
- You can no longer pass a custom expectation repository
or a custom expectation factory to the
mock()function. These options weren't documented very well and just bloated the API.
verifyandverifyAllnow respect the strictness option (c93c7be)- Add strictness option to improve unexpected call errors (71bb975)
- Allow concrete matcher to be configured for each mock (32c82ba)
- Allow strictness to be configured for each mock (c34bacc)
- Control mock strictness through setDefaults (6590713)
-
Don't record property call stats for function calls (de204a5)
-
Print callback syntax in expectation error message (0bf9633)
-
Remove mock options (8bf2d2d)
8.0.0-beta.0 (2022-07-15)
- You no longer have to remember to call
instancebefore passing the mock to the code under test, because we removed it! The object returned bymock()can now be passed directly to your code. - Expectations now have to be wrapped in a callback
inside
when. This change is necessary to remove theinstancefunction. Before:when(foo.bar()). After:when(() => foo.bar()).
-
deps: update dependency jest-matcher-utils to ~27.3.0 (a287174)
-
deps: update dependency jest-matcher-utils to ~27.4.0 (133a17d)
-
Remove
instance(dc2338d) -
Require callback when setting expectations (b0e46f4)
7.3.0 (2021-09-26)
- Add
It.ismatcher (d0e89b2), closes #252 - Add
strictoption todeepEqualsmatcher (c98ea56), closes #252 #257 - Allow overriding the default matcher (e5d27c8), closes #252
- Expose default
deepEqualsmatcher (7d1d015)
- deps: update dependency jest-matcher-utils to ~27.2.0 (8a68c86)
7.2.1 (2021-09-08)
- Make
instancereferentially stable (4194526)
7.2.0 (2021-09-06)
- Add
It.willCapture(987e391)
7.1.2 (2021-08-28)
- Allow other strong mocks in expectations (569815b), closes #254 #256
- deps: update dependency jest-matcher-utils to ~27.1.0 (b024ed0)
7.1.1 (2021-08-26)
7.1.0 (2021-06-24)
- Correctly throw error values from method expectations (a1ad324)
7.0.0 (2021-06-17)
- Node 10 is no longer supported.
- Allow mock instances to be enumerable (850223c), closes #235
- Print promise values in error messages (bc0301f)
- deps: update dependency jest-matcher-utils to ~26.2.0 (52e9740)
- deps: update dependency jest-matcher-utils to ~26.3.0 (b7f483b)
- deps: update dependency jest-matcher-utils to ~26.4.0 (3fe4f66)
- deps: update dependency jest-matcher-utils to ~26.5.0 (b496bcf)
- deps: update dependency jest-matcher-utils to ~26.6.0 (7e25d8c)
- deps: update dependency jest-matcher-utils to v27 (ed3740b)
- deps: update dependency lodash to ~4.17.0 (8c192bc)
- Use node 12 (d30054a)
6.0.0 (2020-06-27)
- Rename
isObjectContainingtoisObject
- Add isNumber matcher (cc5b0a8)
- Add isString (6d5980f)
- Add It.isArray (2359b43)
- Add verifyAll and resetAll (eef45e0)
- Improve error message when setting expectation on nested property (f1ebabe)
- Make matching any object easier (6011775)
- Support nested matchers (c3157b1)
- deps: update dependency jest-matcher-utils to ~26.1.0 (7884b7d)
- Make isNumber pretty print consistently with other matchers (bc5f4f8)
- Make isString pretty print consistently with other matchers (3b6d9e8)
- Make mocks pretty-format-able (73200db)
5.0.1 (2020-05-07)
- Clear unexpected calls on
reset()(04493f7)
5.0.0 (2020-05-07)
- Improve error message for
UnexpectedCalls(ff8636c)
5.0.0-beta.1 (2020-05-05)
- Don't mark toString accesses as unexpected (20247b6)
5.0.0-beta.0 (2020-05-05)
verifyused to rely on unexpected calls throwing when they were made. However, the code under test couldtry..catchthat error and never bubble it up to the test. Unless the test explicitly checked that the SUT was not in an error state,verifywould have not been enough to make sure that everything was correct. Now it throws if any unexpected calls happened.
- deps: update dependency jest-matcher-utils to v26 (5ae654d)

