Jest = Can not find module
remijean opened this issue · comments
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>
)
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 :
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.
Any updates about this? neat solution?