---
title: "Comment by Lars Ejaas on \"Mocking in Jest with TypeScript and React\" | Hashnode"
description: "Hi Rubert Finally got to try this out in a project. I am however struggling with the following error: TypeError: xxxxx.mockImplementation is not a function Have"
url: "https://hashnode.com/posts/mocking-in-jest-with-typescript-and-react/60e06c0903707d644a50080d/comment/61ed5d8aa12088017fbec05a"
---

[Discussion](https://hashnode.com/posts/mocking-in-jest-with-typescript-and-react/60e06c0903707d644a50080d)

Comment [Mocking in Jest with TypeScript and React](https://hashnode.com/posts/mocking-in-jest-with-typescript-and-react/60e06c0903707d644a50080d)

[Lars Ejaas](https://hashnode.com/@LarsEjaas)

[Jan 23, 2022](https://hashnode.com/posts/mocking-in-jest-with-typescript-and-react/60e06c0903707d644a50080d/comment/61ed5d8aa12088017fbec05a)

Hi Rubert

Finally got to try this out in a project. I am however struggling with the following error:

```
TypeError: xxxxx.mockImplementation is not a function
```

Have you seen something like this before? Do you need to setup something specifically to handle mocks in jest.setup.ts or jest.config.js?

[Rupert McKay](https://hashnode.com/@fildon)

[Jan 24, 2022](https://hashnode.com/posts/mocking-in-jest-with-typescript-and-react/60e06c0903707d644a50080d/comment/61ed5d8aa12088017fbec05a#reply-61ee5cebc99aed184e726586)

In general, any time you see "foo is not a function" that suggests that you have an undefined reference.

If you've followed along with the post above, the possible points of failure are either forgetting to `jest.mock` the relevant module path (e.g. `jest.mock('my/path')`) or forgetting to cast a mock type using the original type as the base (e.g. `const mockFoo = foo as jest.MockedFunction<typeof foo>`).

[Lars Ejaas](https://hashnode.com/@LarsEjaas)

[Jan 24, 2022](https://hashnode.com/posts/mocking-in-jest-with-typescript-and-react/60e06c0903707d644a50080d/comment/61ed5d8aa12088017fbec05a#reply-61ee6415c99aed184e726692)

[Rupert 'fildon' McKay](https://hashnode.com/@fildon) Thanks Rupert. I will give it another go! I have another syntax to use, but yours looks so much more elegant, and I sometimes get edgecases where your pattern would be very helpful. Thanks again for a great article! There is way to little material out there on writing good tests. Best regards Lars
