All notable changes to this project will be documented in this file. See standard-version for commit guidelines.
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
instance
before 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 theinstance
function. - The default matcher option previously available only in
setDefaults
has 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
unexpectedProperty
option. - 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
exactParams
option (31acbbe) - Add
unexpectedProperty
option - Allow concrete matcher to be configured for each mock (32c82ba)
- Don't treat
any
returns as promises (9304492)
8.0.0-beta.2 (2022-09-26)
- The
strictness
option has been renamed tounexpectedProperty
to better illustrate its intent.
- Add
exactParams
option (31acbbe)
-
deps: update dependency jest-matcher-utils to v28 (33fe92a)
-
Don't treat
any
returns as promises (9304492) -
Rename option (db9cc06)
8.0.0-beta.1 (2022-08-18)
- The default matcher option previously available only in
setDefaults
has 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.
verify
andverifyAll
now 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
instance
before 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 theinstance
function. 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.is
matcher (d0e89b2), closes #252 - Add
strict
option todeepEquals
matcher (c98ea56), closes #252 #257 - Allow overriding the default matcher (e5d27c8), closes #252
- Expose default
deepEquals
matcher (7d1d015)
- deps: update dependency jest-matcher-utils to ~27.2.0 (8a68c86)
7.2.1 (2021-09-08)
- Make
instance
referentially 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
isObjectContaining
toisObject
- 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)
verify
used to rely on unexpected calls throwing when they were made. However, the code under test couldtry..catch
that error and never bubble it up to the test. Unless the test explicitly checked that the SUT was not in an error state,verify
would 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)