I am not expert in jest, but my recommendation to think about:

1) When the function is exported as default I use something like:

import Funct1 from "../../../src/components/Funct1";
...
jest.mock("../../../src/components/Funct1");
...
expect(Funct1).toHaveBeenCalledWith(params);

2) When the module (utils.js) has multiple exports as

export const f1 = () => {};
...
export const f8 = () => {};

You can try

import * as Utils from "../../../src/components/utils"
const f8Spy = jest.spyOn(Utils, 'f8');
...
expect(f8Spy).toHaveBeenCalledWith(params);

Similar discussion here

Answer from Dima Dorogonov on Stack Overflow
🌐
Medium
medium.com › @catherineangelr › testing-with-spy-and-mock-in-jest-a-beginners-guide-7a25f87010c2
Testing with Spy, Mock, and Stub in Jest: A Beginner’s Guide | by Catherine Angel | Medium
May 21, 2024 - In the example above, a spy function is created on the childFunction . This enables us to track the function while allowing it to be called normally. Then in the test case where parentFunction is called, we can check the whether the childFunction is called or not and confirms that the argument it receives matched the test argument.
🌐
Chakshunyu
chakshunyu.com › blog › how-to-spy-on-a-named-import-in-jest
How To Spy On An Exported Function In Jest | A technical blog by Chak Shun Yu
September 3, 2021 - But in this case, we’re trying to spy on an imported function so we don’t have such an object available. Luckily, there is a simple way to solve this. To spy on an exported function in jest, you need to import all named exports and provide that object to the jest.spyOn function.
Discussions

testing - How to spyOn a function that is not part of the class under test with Jest and Typescript - Stack Overflow
I'm trying to spy on a function that come from uuidv4 package but I didn't figure out how to do that. More on stackoverflow.com
🌐 stackoverflow.com
Cannot spy on individual functions that are individually exported
Having done a lot of research I cannot find a way to mock functions that are exported with no parent object. For example I'm trying to mock functions exported the following way: module.exports ... More on github.com
🌐 github.com
69
August 22, 2017
Jest mocked spy function, not being called in test
The component: The Input component with the onChange handler: More on stackoverflow.com
🌐 stackoverflow.com
August 7, 2019
reactjs - Jest spy the external function issue - Stack Overflow
If you wish to spy on a function ... as an object like so: import * as errorHelpers from 'path/to/errorHelpers'; ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 0 React JS Jest Unit Testing SpyOn ComponentDidMount action call, Getting Cannot spy on .. property because it is not a function · 0 Jest spy.On() does not call the method in React ... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

What Does Jest.clearallmocks() Function Do?
The jest.clearAllMocks() function clears all the mock.calls, mock.instances, mock.contexts and mock.results properties of all mocks. This function is equivalent to calling a .mockClear() function on every mocked function. It returns the jest object for chaining.
🌐
positioniseverything.net
positioniseverything.net › home › jest spyon: all you need to know about this function
Jest Spyon: All You Need To Know About This Function - Position ...
What Does the Jest.runonlypendingtimers() Function Do in the Program?
The Jest.runOnlyPendingTimers() function only executes the macro-tasks that are currently pending, such as tasks that are queued by setTimeout() or setInterval() functions, when any of the pending macro-tasks schedule the new macro-tasks, those tasks will not be executed by this call. This is useful in a program when the module being tested schedules a setTimeout(), and its callback schedules another setTimeout() recursively. This means the scheduling process never stops. In such situations, using Jest.runOnlyPendingTimers() is useful.
🌐
positioniseverything.net
positioniseverything.net › home › jest spyon: all you need to know about this function
Jest Spyon: All You Need To Know About This Function - Position ...
What Does Jest.restoreallmocks() Do?
The jest.restoreAllMocks() function restores all the mocks back to their original value. This function is equivalent to calling a .mockRestore() function on every mocked function. However, the Jest.restoreAllMocks() only works when the mock is created with Jest.spyOn. The other mocks will be required to be done manually to restore them.
🌐
positioniseverything.net
positioniseverything.net › home › jest spyon: all you need to know about this function
Jest Spyon: All You Need To Know About This Function - Position ...
🌐
Code with Hugo
codewithhugo.com › jest-fn-spyon-stub-mock
Jest .fn() and .spyOn() spy/stub/mock assertion reference · Code with Hugo
November 5, 2019 - Jest spies are instantiated using jest.spyOn(obj, 'functionName'). Note: you can’t spy something that doesn’t exist on the object.
🌐
DhiWise
dhiwise.com › post › grow-testing-efficiency-with-jest-spyon-for-default-exports
A Deep Dive into Jest spyOn for Default Exports
April 30, 2025 - When you spy on only the default export, you might encounter issues if the default export is not an object or a class instance. In such cases, you may need to employ workarounds or adjust your testing strategy. The main difference between a mock function and a spyOn function in Jest is that mocking completely replaces the function with a fake version, while spying wraps the actual function, allowing you to observe its behavior without changing its implementation.
🌐
Jest
jestjs.io › mock functions
Mock Functions · Jest
May 7, 2026 - Mock functions are also known as "spies", because they let you spy on the behavior of a function that is called indirectly by some other code, rather than only testing the output.
🌐
Stack Overflow
stackoverflow.com › questions › 72130740 › how-to-spyon-a-function-that-is-not-part-of-the-class-under-test-with-jest-and-t › 72135911
testing - How to spyOn a function that is not part of the class under test with Jest and Typescript - Stack Overflow
uuid (the function) is not a property of sut, so you can't spy on it. You can load the module in question in your test code, replace the function with a spy, and then run your test (the module is cached, so the sut gets the spy rather than the ...
Find elsewhere
🌐
Position Is Everything
positioniseverything.net › home › jest spyon: all you need to know about this function
Jest Spyon: All You Need To Know About This Function - Position Is Everything
November 12, 2025 - The Jest spyon imported function can be applied on the Jest spyon typescript as well as on JavaScript too. The jest spyon context should be clear when the programmer is using the jest spyon function without an object in the program.
🌐
GitHub
github.com › jasmine › jasmine › issues › 1414
Cannot spy on individual functions that are individually exported · Issue #1414 · jasmine/jasmine
August 22, 2017 - import {thing} from 'emvio-util-responses; //call some function that calls thing() spyOn(???, 'thing').and.returnValue({}); expect(???.thing).toHaveBeenCalled(); I have tried many ways of accomplishing this but the mock is not called. Some suggest importing * and providing an alias as a parent object.
Author   jasmine
🌐
Jest
jestjs.io › the jest object
The Jest Object · Jest
May 7, 2026 - If you get a warning that Symbol.dispose does not exist, you might need to polyfill that, e.g. with this code: ... Since Jest 22.1.0+, the jest.spyOn method takes an optional third argument of accessType that can be either 'get' or 'set', which proves to be useful when you want to spy on a getter or a setter, respectively. ... See TypeScript Usage chapter of Mock Functions page for documentation.
🌐
DEV Community
dev.to › devin-rosario › complete-guide-to-jestspyon-for-unit-testing-4io6
Complete Guide to Jest.spyOn for Unit Testing - DEV Community
October 16, 2025 - Only works with objects, not classes. Common error everyone sees once: TypeError: Cannot read property '_isMockFunction' of undefined. Means your spy target does not exist where Jest looks for it.
🌐
Zirkelc
zirkelc.dev › posts › jest-spy-on-classes
How To Spy on Classes
June 28, 2023 - class Person { static hello() { return 'Hello, I am a static method.'; } goodbye() { return 'Goodbye, I am an instance method.'; } } test('should call instance method of single object', () => { // Create an instance of the class const person = new Person(); // Spy on the instance method const spy = jest.spyOn(person, 'goodbye'); // Invoke the method on the instance person.goodbye(); // Test if the method on the instance has been called expect(spy).toHaveBeenCalled(); }); In many real-world cases, we may not have access to the specific instance of the class we want to spy on.
🌐
Meticulous
meticulous.ai › blog › how-to-use-jest-spyon
How to use Jest spyOn with React.js and Fetch
On the contrary, now it is a bit ... using spyOn on an object method is easier. Jest spyOn can target only the function relevant for the test rather than the whole object or module....
🌐
JavaScript in Plain English
javascript.plainenglish.io › jest-spies-and-mocks-in-explained-via-examples-71229077277f
Jest Spies and Mocks Explained via Examples | by John C. Lokman | JavaScript in Plain English
July 24, 2024 - We have seen two approaches to keeping tabs on the methods in our code. You can use jest.spyOn for a non-intrusive way to record calls. Alternatively, you can use jest.fn to replace a method entirely with a fake version of it, which is called ‘mocking’.
🌐
You.com
you.com › search
jest cannot spy the property because it is not a function; undefined given instead 🔎 Your Personalized AI Assistant.
Conversational and continuously learning, You.com enhances web search, writing, coding, digital art creation, and solving complex problems.
🌐
Medium
medium.com › @DavideRama › mock-spy-exported-functions-within-a-single-module-in-jest-cdf2b61af642
Mock/Spy exported functions within a single module in Jest | by Davide Ramaglietta | Medium
February 14, 2020 - import * as myModule from './myModule';test('calls myModule.foo', () => { const fooSpy = jest.spyOn(myModule, 'foo');myModule.bar();expect(fooSpy).toHaveBeenCalledTimes(1); }); Surprisingly or not, this test would fail with the message Expected mock function to have been called one time, but it was called zero times.: You could try using jest.mock() or any other Jest interface to assert that your bar method depends on your foo method.