Open eard7 opened 5 years ago
edit: I opened #4053 because it seems to be a different issue.
I'm also facing the same type of issue Please find the issue below
Module build failed (from ./node_modules/sass-loader/dist/cjs.js): SassError: Undefined mixin. ╷ 430 │ ┌ @include media-breakpoint-only(sm) { 431 │ │ display: none; 432 │ └ }
I found solution here... https://www.dev-tips-and-tricks.com/use-bootstrap-4-media-query-mixins
For anyone who was looking for an answer like me, I've found a solution of this problem. https://qiita.com/mascii/items/6fd5333b65931b55d38b
You need to insert this code into jest.config.js
module.exports = {
// ...
globals: {
'vue-jest': {
experimentalCSSCompile: false,
},
},
};
Version
3.4.1
Reproduction link
https://github.com/eard7/test-sass-error
Environment info
Steps to reproduce
1.- Create a new project or pull the minimal reproduction repo (and npm install)
2.- Add scss mixins or variables as globals
3.- Add a Demo component and use any of the mixins you added (It doesn't matter if its on a separate scss file or inside the style tags in the vue file)
4.- Create a unit test for your Demo component
4.- Run
npm run serve
and in a separate terminal tab runnpm run test
What is expected?
When running the serve command, the application should pull your sass mixing properly. Also you should be able to run the tests properly
What is actually happening?
Run the serve command works and you can see the application is pulling the mixin properly, but running the tests leads to an error that prevent the tests completion.
This setup is using sass (dart sass), but a similar issue happens using node-sass. Seems like if the test mode is using a different configuration. In fact in the vue.config.js file a workaround is needed to be able to load global sass mixins/vars in test mode (you can see that workaround on the minimal reproduction repo)