Putting in a small snippet below :
import xyz from '../xyz'
function calculate() {
return xyz(arg1, arg2).catch((err) => {
func1()
func2()
})
}
export default calculate
I'm just trying to assert that xyz is called in jest. How can I do it ?
I tried the following but doesn't work :
import * as myModule from '../xyz'
import calculate from '../../calculate'
const mock = jest.spyOn(myModule, 'xyz')
mock.mockReturnValue('mocked value')
const op = calculate()
expect(op).toBe('mocked value')
This gives me the following error:
Cannot spy the xyz property because it is not a function; undefined given instead