chakra-ui / panda

🐼 Universal, Type-Safe, CSS-in-JS Framework for Product Teams ⚡️
https://panda-css.com
MIT License
5.23k stars 236 forks source link

Jest error with `styled-system` directory #2242

Closed mattupham closed 8 months ago

mattupham commented 8 months ago

Description

Jest error with styled-system directory

jest error:

Could not locate module @styled/css

    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^@styled\/(.*)$/": "/Users/../styled-system/$1"
      },
      "resolver": undefined
    }

tsconfig:

"paths": {
      "@styled/*": ["./styled-system/*"]
}

I've tried all of these steps to attempt a fix:

Jest Issues

Link to Reproduction

n/a

Steps to reproduce

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See error

JS Framework

React, Nextjs, Typescript

Panda CSS Version

"@pandacss/dev": "^0.28.0",

Browser

Chrome

Operating System

Additional Information

No response

anubra266 commented 8 months ago

@mattupham This is not a panda issue, you need to make your jest configuration find your paths https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring

mattupham commented 8 months ago

@mattupham This is not a panda issue, you need to make your jest configuration find your paths https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring

Thank you for the quick reply! I've tried the recommendations with moduleNameMapper - haven't got anything to work here yet. Is there anything specific you recommend?

anubra266 commented 8 months ago

@mattupham I'm not too familiar with Jest. Got that after a google search. You can try something like this

moduleNameMapper: {
  "@styled/(.*)": "<rootDir>/styled-system/*/$1",
}
mattupham commented 8 months ago

@mattupham I'm not too familiar with Jest. Got that after a google search. You can try something like this

moduleNameMapper: {
  "@styled/(.*)": "<rootDir>/styled-system/*/$1",
}

Thanks! Unfortunately this didn't work as well. Does Panda have any other recommendation of working with jest, or any examples?