Mock functions (jest.fn()) violates instanceof Function test.
Steps to reproduce the behavior:
describe('jest.fn', () => {
expect(typeof jest.fn()).toBe('function') // OK
expect(jest.fn() instanceof Function).toBe(true); // FAIL
});
Mock function should not break instanceof Function test.
npx envinfo --preset jestPaste the results here:
•100% ➜ npx envinfo --preset jest
npx: installed 1 in 7.84s
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Binaries:
Node: 8.10.0 - ~/.anyenv/envs/ndenv/versions/v8.10.0/bin/node
Yarn: 1.6.0 - ~/.anyenv/envs/ndenv/versions/v8.10.0/bin/yarn
npm: 5.6.0 - ~/.anyenv/envs/ndenv/versions/v8.10.0/bin/npm
npmPackages:
@types/jest: ^22.2.0 => 22.2.0
jest: ^22.4.3 => 22.4.3
Running in to the same problem when trying to use jest.fn() as a prop to a third party react library that has invariant checks on its props
Same problem here. I was trying to figure out why my coverage was not good. I noticed that even I dispatched an action with a mockFunction it was not being called:

What do you suggest is the best approach in the meantime this bug is resolved ?
I changed instanceof for typeof but I prefer to use the former because it check actual types rather than string. It is also faster.
Thank you
I am currently working around this issue by wrapping my mock in a normal function that delegates the call to the target jest mock:
const mock = jest.fn();
const mockWrapper = function (...args) {
return mock(...args);
}
````
For instance in the above example posted by sandinosaso that may look like:
```javascript
const mockOnClick = jest.fn();
const component = mountWithTheme(
// Wrap the mock in a function which directly calls the mock
<Tag data={tagData} onClick={(...args) => mockOnClick(...args)} />
);
component.find('StyledTag').simulate('click');
expect(mockOnClick).toHaveBeenCalled();
expect(jest.fn()).toBeInstanceOf(jest.fn().constructor);
or better yet
expect(jest.fn()).toEqual(expect.any(Function));
This is a duplicate of #2549. Help solving that would be very much appreciated! It has a bounty of $499
Most helpful comment
I am currently working around this issue by wrapping my mock in a normal function that delegates the call to the target jest mock: