gaoxiaoliangz/react-scoped-css

Problem with Test with jest

Closed this issue · 1 comments

I have a problem trying to test a component that imports another component with .scoped.scss.
Something along these lines:

- components
   - some-component.tsx
- pages
   - some-page.tsx // this imports the some-component

When I run a test I get the error:
Cannot find module: some-component.scoped.scss?scopeId=xxxxx

I already configured jest.config with moduleNameMapper '\.(css|scss|sass)$': 'identity-obj-proxy',

add this to moduleNameMapper in jest.config:
'\\.scoped.(css|scss)': 'identity-obj-proxy',