I mocking a function, and for some reason, the code is still running the original function, I made sure that the function is indeed mocked using isMockFunction,
import { getTables, getExportFiles } from 'rds-formatter';
jest.mock('rds-formatter', () => {
return {
...jest.requireActual('rds-formatter'),
getExportFiles: jest.fn(() => Promise.resolve('return something')),
});
Now the thing is Im testing an asyncGenerator function
export async function *getTables(assetId: string, payload: Record<string, unknown>) {
const { parquetFiles, tablesInfoFile } = await getExportFiles(s3Client, payload);
return parquetFiles }
My test looks like this:
it('', async () => {
console.log(jest.isMockFunction(getExportFiles)); //returns true
const data = getTables('gfsdg', payload)
expect((await data.next()).value).toBe('')
});
The error I'm getting is s3Client.listObjectsV2 is not a function
This error is from inside the function I'm trying to mock, I know this happens because I'm not passing a real client, but from my understanding the compiler shouldn't even go inside the mocked function, no?