I'm trying to run frontend unit tests in my Angular app using Karma. I can't get the tests to compile though, when running 'ng test' in the console it fails with this error message:
Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
1 │ @use 'internal-library' as *;
│ ^^^^^^^^^^^^^^^^^^^^^^
╵
../../../src/styles/global.scss 1:1 @import
../../../src/styles/styles.scss 8:9 root stylesheet
How can I exclude compiling stylesheets from karma? Or is there another solution I should try?
Re: the first comment, I updated my angular.json as the other answer suggested, with this:
"styles": [
"src/styles/styles.scss"
],
"stylePreprocessorOptions": {
"includePaths": [
"src/styles"
]
},
(Adapted to my file structure)
-src
-styles
-global.scss -> here's the import it's struggling with
-styles.scss -> the global file is then imported here
-api
-mixins.scss
-variables.scss