Replies: 1 comment 2 replies
-
But, to fix your issue you have to mock it, using If your question is why, those are empty, it is because, your file is processed before executed, and those declarations you made, are replaced, either by turbopack, or through a loader, into something like this: module.exports = {
"style": {
"fontFamily": "'Geist Mono', 'Geist Mono Fallback'",
"fontStyle": "normal"
},
"className": "__className_ea5f4b",
"variable": "__variable_ea5f4b"
}; Which is why you can then do But for your use case, |
Beta Was this translation helpful? Give feedback.
-
Summary
I'm using
vitest
to add tests for my Next.js project (first time user of both here) based on the instructions from https://nextjs.org/docs/app/building-your-application/testing/vitest.Similar to #59701, I'm getting the next error:
src/components/Fonts.tsx
is being imported bysrc/app/layout.tsx
, that's being imported bysrc/app/layout.test.tsx
. Full content ofsrc/components/Fonts.tsx
is:Problem is that
Inter
(and by extension,SansFont
) isundefined
, but content ofnode_modules/next/font/google/index.js
is in fact empty! 😮 So it's exporting an empty object, and obviously everything isundefined
.node_modules/next/font/google/index.d.ts
just only exports everything fromnode_modules/next/dist/compiled/@next/font/google/index.js
... that in fact exports nothing at all, so also an empty object by default, just throw an exception (that's NOT being thrown, so code is not being executed and seems to be correctly configured):I'm having some similar issues with other
react
imports, so it seems something is wrong with the config, but I don't know where to start looking for. Any help or clarification is welcome, so don't doubt asking me.Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions