I have a module which exports a function:
// module.js
export function doSomething() {
// ...
}
I need to mock this function in tests. According to this answer, I can do the following:
// module.test.js
import * as module from './module';
it('does something', () => {
module.doSomething = jest.fn(() => console.log('Something was done'))
// test
})
This code works (the function implementation is being replaced), but Flow is unhappy: Error:(101, 3) Flow: assignment of property 'doSomething'. Mutation not allowed on exports of "./module"
I can't seem to find any information about this particular error (both Google and Stack Overflow search give me exactly 0 results).
Are these complaints justified or can I just ignore them?
If it's the latter, what's the way to explain to Flow that this is nothing to worry about (other than using // $FlowExpectedError
in every case)?