Suppose I have a simple file exporting a default function:
// UniqueIdGenerator.js const uniqueIdGenerator = () => Math.random().toString(36).substring(2,
In some cases you have to mock the import to be able to spy the default export:
import * as fetch from 'node-fetch' jest.mock('node-fetch', () => ({ default: jest.fn(), })) jest.spyOn(fetch, 'default')