Mock Global Function in a Single Test
Problem
Trying to mock a global function in a test file,not for all tests.
Solution
To do it:
- import the whole file, not just the function
- 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 global.xxx
import * as storeHelper from 'src/app/shared/functions/store-helper';
// mock the function
(storeHelper as any).getCurrentValue = () => 1233;