diff --git a/lib/compilers/scss-compiler.js b/lib/compilers/scss-compiler.js
index 086c8575..5b7a0885 100644
--- a/lib/compilers/scss-compiler.js
+++ b/lib/compilers/scss-compiler.js
@@ -27,7 +27,7 @@ module.exports = (content, filePath, config) => {
}
let result
try {
- sass.renderSync({
+ result = sass.renderSync({
data: scssResources + rewriteImports(content, filePath),
outputStyle: 'compressed'
}).css.toString()
diff --git a/lib/process.js b/lib/process.js
index 3e41c763..1e564438 100644
--- a/lib/process.js
+++ b/lib/process.js
@@ -84,22 +84,29 @@ module.exports = function (src, filePath, jestConfig) {
}
if (Array.isArray(parts.styles) && parts.styles.length > 0) {
- if ((parts.styles.some(ast => /^scss|sass|less|pcss|postcss/.test(ast.lang))) && logger.shouldLogStyleWarn) {
+ if ((parts.styles.some(ast => /^sass|less|pcss|postcss/.test(ast.lang))) && logger.shouldLogStyleWarn) {
!config.hideStyleWarn && logger.warn('Sass, Less and PostCSS are not currently compiled by vue-jest')
logger.shouldLogStyleWarn = false
}
- const styleStr = parts.styles.map(ast => {
- if (!module) return
-
- const styleObj = (/^sass|less|pcss|postcss/.test(ast.lang))
- ? {}
- : processStyle(ast, filePath, config)
-
- const moduleName = ast.module === true ? '$style' : ast.module
-
- return '\n this[\'' + moduleName + '\'] = ' + JSON.stringify(styleObj)
- }).filter(_ => _)
+ const styleStr = parts.styles
+ .filter(ast => module && ast.module)
+ .map(ast => {
+ const styleObj = (/^sass|less|pcss|postcss/.test(ast.lang))
+ ? {}
+ : processStyle(ast, filePath, config)
+
+ const moduleName = ast.module === true ? '$style' : ast.module
+
+ return `
+ if(!this['${moduleName}']) {
+ this['${moduleName}'] = {};
+ }
+ this['${moduleName}'] = Object.assign(this['${moduleName}'], ${JSON.stringify(styleObj)});
+ `
+ })
+ .filter(_ => _)
+ .join('')
if (styleStr.length !== 0) {
output += '\n;(function() {' +
diff --git a/test/resources/Sass.vue b/test/resources/Sass.vue
index 15332c06..77a258d3 100644
--- a/test/resources/Sass.vue
+++ b/test/resources/Sass.vue
@@ -4,8 +4,7 @@