//CustomConfigurator.ts
export default function customizeConfig(name: string): string {
// add some custom logic here
return output;
}
//CustomUtility.ts
import customizeConfig from './CustomConfigurator';
export default class CustomUtility {
public static checkIfFoo(): boolean {
const customizedConfig = customizeConfig();
return customizedConfig == 'Foo';
}
}
//CustomUtility.test.ts
import CustomUtility from '../CustomUtility';
import * as customConfig from '../CustomConfigurator';
const configMock = customConfig.default as jest.Mock;
describe('tests', () => {
it('sample test case', async () => {
configMock.mockReturnValue('mocked-configuration');
const fooCheck = CustomUtility.checkIfFoo();
});
});
I attempted to mock the customizeConfig function from CustomConfigurator.ts in CustomUtility.test.ts. I encountered an error 'configMock.mockReturnValue is not a function'.
Is there a way to properly mock an exported default function?