Trying to mock a global function in a test file,not for all tests.


To do it:

  1. import the whole file, not just the function
  2. type the import as type any and create a mock for the particular function you want to mock

Code example:

// import whole file because we dont want to use
import * as storeHelper from 'src/app/shared/functions/store-helper';

// mock the function
(storeHelper as any).getCurrentValue = () => 1233;