Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 'Can't find stylesheet to import' with CSS Modules with SCSS #311

Open
JusteZil opened this issue Jan 29, 2024 · 0 comments
Open

Error 'Can't find stylesheet to import' with CSS Modules with SCSS #311

JusteZil opened this issue Jan 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JusteZil
Copy link

JusteZil commented Jan 29, 2024

Describe the bug

If users use jest-preview with vite, CSS modules with SCSS and import stylesheet with an absolute import like this @import 'src/styles', the following error is thrown:

● Test suite failed to run. 

Can't find stylesheet to import.
  ╷
1 │ @import 'src/styles';
  │         ^^^^^^^^^^^^
  ╵
  src\components\Button\Button.module.scss 1:9  root stylesheet

I attempted to utilize the sassLoadPaths configuration option and set up jest moduleNameMappers such as 'src/(.*)': '<rootDir>/src/$1', but it appears that none of these changes are taking effect.
Using a relative import could be a solution to the problem; however, implementing such a change in the existing project is not feasible.

Screenshots

Folder structure:
image

Import example:
image

Error:
image

Reproduce

You can find a minimal reproducible example in this repository, and its code is adapted from the example demonstrated in jest-preview vite-react-example.

Expected behavior

No errors

Environment

  • OS: Windows 11
  • jest: ^27.5.1
  • jest-preview: ^0.3.1
  • postcss: ^8.4.16
  • sass: ^1.50.0
  • vite: ^2.8.0

Additional context

Seems that the same issue was already reported in #224 without further resolution.

@JusteZil JusteZil added the bug Something isn't working label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant