I am trying to export a function that is a const inline function and use it in a jest module, but I am getting the error
TypeError: (0 , _utils.reverseMapper) is not a function
I don't know why this happens because the function I am calling doesn't rely on/ call this function at all, and its not in the same module as getJson()
I have tried to import vs require (since its a variable) but neither of these work
so far I am doing the following
import { getJson } from "../myUtils";
jest.mock('../myUtils', () => ({
getJson: jest.fn(),
}));
then in my test:
const configs = {
policies:['something']
};
it('Failed to load the userid', async () => {
ObjectIdDecrypt.mockImplementationOnce(() => '6536');
mpds.getBizInfo.mockImplementationOnce(() => Promise.resolve(info));
user.userSearch.mockImplementationOnce(() =>
Promise.resolve(errorResponse)
);
getJson.mockImplementation( () => configs);
try {
await somethingElse(
{
input: {
timezone: 'America/New_York',
},
},
{ req: getMockReq() }
);
expect.fail('Expected to throw error');
} catch (err) {
expect(err).toBeDefined();
expect(err.message).toEqual('User does not exist');
expect(err.extensions.name).toEqual('INVALID_REQUEST');
}
});
hoping someone can help me understand why jest is throwing this error