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

Jest = Can not find module #7

Open
remijean opened this issue Jul 11, 2019 · 3 comments
Open

Jest = Can not find module #7

remijean opened this issue Jul 11, 2019 · 3 comments

Comments

@remijean
Copy link

Hello,

I have a problem with Jest, when I run a test I have this error:

Cannot find module 'sass-extract-loader?{"plugins": ["sass-extract-js"]}!./theme/variables.scss' from 'index.tsx'

My code :

const theme = require('sass-extract-loader?{"plugins": ["sass-extract-js"]}!./theme/variables.scss')

ReactDOM.render(
  <ThemeProvider theme={theme}>
    ...
  </ThemeProvider>
)
@parthmakadiya12
Copy link

I am facing the same issue :

There is a way to solve this with jest-webpack-resolver

just define a file jest.config.js

and put this inside

  modulePaths: [
    "./node_modules/sass-extract-js/sass-extract-js.js",
    "./node_modules/sass-extract-loader/index.js"
  ];

Still, I am not happy with this solution :
I hope we can get a better solution :

@adi518
Copy link

adi518 commented Aug 12, 2019

Anyone find a better workaround? jest-webpack-resolver is not a flexible solution, as it depends on a static Webpack configuration file, which means it can't work with abstracted configuration like CRA.

@justgeek
Copy link

Any updates about this? neat solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants