Skip to content

Latest commit

 

History

History
393 lines (229 loc) · 20.8 KB

CHANGELOG.md

File metadata and controls

393 lines (229 loc) · 20.8 KB

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

9.0.1 (2024-11-23)

Bug Fixes

  • 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
before after

⚠ BREAKING CHANGES

  • isObject has been replaced by isPlainObject and containsObject
  • Merge isString's optional containing and matching args
  • Rename the toJSON matcher method to toString
  • Don't allow empty partials in containsObject

Features

  • Attach actual/expected args to error instance to enable IDE diffs (7a04a43)
  • Improve isArray diff (a5aaddd)
  • Improve isNumber diff (55647ed)
  • Improve isObject diff (5533bcf)
  • Improve isString diff (5c73fbb)
  • Improve willCapture diff (7d92ce9)
  • Improve colors in UnexpectedCall error message (f326954)
  • Pretty print argument diffs in UnexpectedCall error messages (ba4f6b5)

Bug Fixes

  • Fix isPartial allowing unexpected keys (cc0b881)
  • Fix isPartial not working with interfaces (169b336)
  • isObject now correctly fails for null and undefined (9b50fe4)
  • Fix It docstrings (df7f91a)
  • Handle non string keys in isObject (87cb768)

9.0.0-beta.3 (2024-05-23)

⚠ BREAKING CHANGES

  • Don't allow empty partials in containsObject
  • Rename isPartial to containsObject

Features

  • Don't allow empty partials in containsObject (6c76608)

Bug Fixes

  • Fix isPartial allowing unexpected keys (cc0b881)

  • Rename isPartial to containsObject (a2c3c76)

9.0.0-beta.2 (2024-05-22)

Bug Fixes

  • Fix isPartial not working with interfaces (169b336)

9.0.0-beta.1 (2024-05-22)

⚠ BREAKING CHANGES

  • isObject has been replaced by isPlainObject and isPartial.

Features

9.0.0-beta.0 (2023-09-24)

⚠ BREAKING CHANGES

  • Merge isString's optional containing and matching args
  • Rename the toJSON matcher method to toString
  • isObject now correctly fails for null and undefined

Features

  • Attach actual/expected args to error instance to enable IDE diffs (7a04a43)
  • Improve isArray diff (a5aaddd)
  • Improve isNumber diff (55647ed)
  • Improve isObject diff (5533bcf)
  • Improve isString diff (5c73fbb)
  • Improve willCapture diff (7d92ce9)
  • Improve colors in UnexpectedCall error message (f326954)
  • Pretty print argument diffs in UnexpectedCall error messages (ba4f6b5)

Bug Fixes

  • isObject now correctly fails for null and undefined (9b50fe4)

  • Fix It docstrings (df7f91a)

  • Handle non string keys in isObject (87cb768)

  • Merge isString's optional containing and matching args (f53a05e)

  • Rename the toJSON matcher method to toString (95ffd6b)

8.0.1 (2023-01-18)

Bug Fixes

  • 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.

⚠ BREAKING CHANGES

  • 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 by mock() 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 the instance function.
  • The default matcher option previously available only in setDefaults has been renamed to concreteMatcher.
  • 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.

Features

  • Add exactParams option (31acbbe)
  • Add unexpectedProperty option
  • Allow concrete matcher to be configured for each mock (32c82ba)

Bug Fixes

  • Don't treat any returns as promises (9304492)

8.0.0-beta.2 (2022-09-26)

⚠ BREAKING CHANGES

  • The strictness option has been renamed to unexpectedProperty to better illustrate its intent.

Features

Bug Fixes

  • 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)

⚠ BREAKING CHANGES

  • The default matcher option previously available only in setDefaults has been renamed to concreteMatcher.
  • 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.

Features

  • verify and verifyAll 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)

Bug Fixes

  • 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)

⚠ BREAKING CHANGES

  • 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 by mock() 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 the instance function. Before: when(foo.bar()). After: when(() => foo.bar()).

Bug Fixes

  • 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)

Features

Bug Fixes

  • deps: update dependency jest-matcher-utils to ~27.2.0 (8a68c86)

7.2.1 (2021-09-08)

Bug Fixes

  • Make instance referentially stable (4194526)

7.2.0 (2021-09-06)

Features

7.1.2 (2021-08-28)

Bug Fixes

  • 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)

Features

  • thenReject now lazily creates promise rejection (01c9995), closes #238

Bug Fixes

  • Correctly throw error values from method expectations (a1ad324)

7.0.0 (2021-06-17)

⚠ BREAKING CHANGES

  • Node 10 is no longer supported.

Features

  • Allow mock instances to be enumerable (850223c), closes #235
  • Print promise values in error messages (bc0301f)

Bug Fixes

  • 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)

build

6.0.0 (2020-06-27)

⚠ BREAKING CHANGES

  • Rename isObjectContaining to isObject

Features

  • 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)

Bug Fixes

  • 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)

Bug Fixes

  • Clear unexpected calls on reset() (04493f7)

5.0.0 (2020-05-07)

Features

  • Improve error message for UnexpectedCalls (ff8636c)

5.0.0-beta.1 (2020-05-05)

Bug Fixes

  • Don't mark toString accesses as unexpected (20247b6)

5.0.0-beta.0 (2020-05-05)

⚠ BREAKING CHANGES

  • verify used to rely on unexpected calls throwing when they were made. However, the code under test could try..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.

Features

  • Record unexpected calls (a87f612)
  • Throw on unexpected calls when verifying mock (f68e2f2)

Bug Fixes

  • deps: update dependency jest-matcher-utils to v26 (5ae654d)