I am developing a UI library using MUI, React, and TypeScript, with Nx as the build system. For testing purposes, I am using Jest. However, I encountered an error when trying to add a font to my project following the instructions provided in the Next.js documentation.
The code snippet causing the issue is as follows:
import localFont from 'next/font/local';
const myFont = localFont({ src: './my-font.woff2' });
When running Jest tests, I receive the following error message:
TypeError: (0, _local.default) is not a function
I would appreciate any insights or suggestions on how to resolve this error and successfully add the font to my project while using Jest for testing. Thank you!
I expect that the localFont
function from next/font/local
should be successfully imported and executed without any errors in the Jest environment. The myFont
variable should be assigned the appropriate value, allowing me to use the font in my UI library. I would like to understand why the error message "TypeError: (0, _local.default) is not a function" is occurring and find a solution to resolve it.