twin.macro icon indicating copy to clipboard operation
twin.macro copied to clipboard

Jest testing (typescript) - twin_macro_1.theme is not a function

Open FedericoCasarella opened this issue 1 year ago • 2 comments

Hey there, so i tried to create a component using the following code (TS):

import tw, { theme } from 'twin.macro'

function Test(){
   const twColor: Record<string, string> = theme`colors`
   const twHeight = theme`height`

   return ( ... )
}

You can view a complete usage inside this template (Elstar-lite)

Once created the component i built a test using jest just trying to render it and jest throws error TypeError: (0, twin_macro_1.theme) is not a function

on line:

const twColor: Record<string, string> = theme`colors` 

Hope i've been clear 👍 . Thank you!

FedericoCasarella avatar Dec 06 '23 08:12 FedericoCasarella

Check out some of the examples for setup info, like the styled-components-vite example - in your package.json I couldn't see any css-in-js lib installed or configured.

ben-rogerson avatar Dec 06 '23 09:12 ben-rogerson

Any suggestion to fix it?

kundalee avatar Apr 13 '24 11:04 kundalee