Say I have the following code:
export const exampleFunc = () => {}
Which is then used in a test like so:
import * as exampleAll from '../../path/to/example'
describe('Example', () => {
exampleAll.exampleFunc = jest.fn()
})
This fails to typecheck with:
Cannot assign jest.fn() to exampleAll.exampleFunc because property exampleFunc is not writable.
44│ const mockStore = configureStore([reduxThunk])
45│
46│ describe('[Redux action] ExampleAction()', () => {
47│ exampleAll.exampleFunc = jest.fn()
48│ beforeEach(() => {
49│ exampleAll.exampleFunc.mockReturnValue(() => () => {})
50│ })
Why is it not writable? And how can I do such mocking while also using flow?
Thanks!