Open jpasquers opened 2 years ago
I created a repository showcasing this:
https://github.com/jpasquers/jest-mock-extended-fail-example
The important part being the following
import { mockDeep } from "jest-mock-extended"; interface X { y: { [a: string]: string } z: { z1: string; } } describe('nested mock', () => { it('should be empty inner object', () => { let mock = mockDeep<X>({y: {}}); //This fails -> Received: [Function mockConstructor] expect(mock.y["something"]).toBeUndefined(); }) })
Since I am providing an implementation of y that is {} shouldn't mock.y["something"] be undefined?
{}
mock.y["something"]
Just ran into this surprise as well.
Edit - using undefined instead of an empty object literal {} ended up working for me:
undefined
mockDeep<X>({y: undefined});
I created a repository showcasing this:
https://github.com/jpasquers/jest-mock-extended-fail-example
The important part being the following
Since I am providing an implementation of y that is
{}
shouldn'tmock.y["something"]
be undefined?