Jest variable outside function is undefined while testing function

below is a function i want to test

import { logger } from 'logger';
const log = logger(__filename);

export const foo = () => {
 log('test log');
};

below is my test case

import { foo } from '../../src/utils/foo';
import * as utils from 'logger';
jest.mock('logger');
// eslint-disable-next-line no-undef
const mockedFoo = jest.mocked(utils, true);

describe('Common Utils', function () {
  describe('#foo', function () {
   it('foo', () => {
      // eslint-disable-next-line no-undef
      mockedFoo.logger.mockReturnValueOnce(() => { return { log: jest.fn() }; });
      await foo();
      expect(mockedFoo.logger).toHaveBeenCalledWith('test');
    });
  });
});

when i try to run it gives error log is not defined, it cannot get out of scope variable