I'm trying to mock an object like this:
export default person = { firstName: "xxx", LastName: "xxx", getFullName: () => this.firstName + this.LastName } jest.mock('../person', () => ({ getFullName: () => "John Smith" }));
So I just want to mock the getFullName method, but when I run jest, I find that person is mocked as:
{ default: { getFullName: () => "John Smith" } ... }
How can I get rid of the "default" properties that I only want:
{ getFullName: () => "John Smith" }
You can replace mock with spyOn method.
jest.spyOn(person, 'getFullName').mockImplementation(() => "John Smith");