nestjs-multer-extended icon indicating copy to clipboard operation
nestjs-multer-extended copied to clipboard

chore(deps): update dependency jest-when to v3.6.0

Open renovate[bot] opened this issue 2 years ago β€’ 0 comments

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
jest-when 3.4.0 -> 3.6.0 age adoption passing confidence
@types/jest-when (source) 2.7.3 -> 3.5.5 age adoption passing confidence

Release Notes

timkindberg/jest-when (jest-when)

v3.6.0

Compare Source

v3.5.2

Compare Source

v3.5.1: Support @​golevelup/ts-jest and jest-mock-extended proxies

Compare Source

v3.5.0: Default Behavior Methods

Compare Source

New methods:

  • defaultReturnValue
  • defaultResolvedValue
  • defaultRejectedValue
  • defaultImplementation

Use them to set up a default behavior, which will serve as fallback if no matcher fits.

when(fn)
  .calledWith('foo').mockReturnValue('special')
  .defaultReturnValue('default') // This line can be placed anywhere, doesn't have to be at the end

expect(fn('foo')).toEqual('special')
expect(fn('bar')).toEqual('default')

Previously you needed to use any of mockReturnValue, mockResolvedValue, mockRejectedValue, or mockImplementation directly on the object before using calledWith to create a default fallback.

// Same as above example
when(fn)
  .mockReturnValue('default')
  .calledWith('foo').mockReturnValue('special')

One neat idea, and the reason I even did this work, is to set up a default implementation that throws an error if an improper call is made to the mock.

when(fn)
  .calledWith(correctArgs)
  .mockReturnValue(expectedValue)
  .defaultImplementation(unsupportedCallError)

// A default implementation that fails your test
function unsupportedCallError(...args) {
  throw new Error(`Wrong args: ${JSON.stringify(args, null, 2)}`);
}
Commits:
  • Merge pull request #​92 from timkindberg/default_methods 67b7532
  • Add several methods to set up default behaviors. These methods can be placed anywhere in the mocking set up, including after other calledWith setups, unlike previous "default" behavior using when(fn).mockReturnValue(z). You can now do: when(fn).calledWith(x).mockReturnValue(y).defaultReturnValue(z). 77fe672
  • Add documentation example for unsupported call error as default implementation a6dc74d

v3.4.2

Compare Source

  • Reset assertionCalls to zero so that our hack doesn't interfere with existing expect.assertions() usage 3a27d0b

v3.4.1

Compare Source

  • Access the equals util by grabbing it from the expect this arg. Temporary hack until core jest exposes this util officially. 5a8cc93

See https://github.com/facebook/jest/issues/11867#issuecomment-934523457


Configuration

πŸ“… Schedule: Branch creation - "every weekday" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• Ignore: Close this PR and you won't be reminded about these updates again.


  • [ ] If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

renovate[bot] avatar Oct 05 '21 17:10 renovate[bot]