This patch fixes the bug where TypeError is thrown in mockReset/mockClear when the mock has properties with null or undefined values.
I encounter this bug when using jest-mock-extended along with jest-when (https://github.com/timkindberg/jest-when/blob/master/src/when.js#L204).
jest-when internally uses __whenMock__ property to store the mock setup, and assign undefined to this once the mock is reset. Calling mockClear or mockReset after that would throw TypeError exception.
This patch fixes the bug where TypeError is thrown in
mockReset
/mockClear
when the mock has properties withnull
orundefined
values.I encounter this bug when using
jest-mock-extended
along withjest-when
(https://github.com/timkindberg/jest-when/blob/master/src/when.js#L204).jest-when
internally uses__whenMock__
property to store the mock setup, and assignundefined
to this once the mock is reset. CallingmockClear
ormockReset
after that would throw TypeError exception.