Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Only test the build of SCSS for supported brand (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
notlee authored Jan 11, 2019
1 parent 6cfdda6 commit 0b6455c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
7 changes: 4 additions & 3 deletions config/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const fileHelpers = require('../lib/helpers/files');
// https://github.com/webpack/webpack/issues/3324#issuecomment-289720345
delete webpackConfig.bail;
module.exports.getBaseKarmaConfig = function() {
return Promise.all([fileHelpers.getModuleName(), fileHelpers.readIfExists(path.resolve('main.scss'))]).then(values => {
return Promise.all([fileHelpers.getModuleName(), fileHelpers.getModuleBrands(), fileHelpers.readIfExists(path.resolve('main.scss'))]).then(values => {
const moduleName = values[0];
const mainScssContent = values[1];
const brands = values[1];
const mainScssContent = values[2];
return {
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
Expand Down Expand Up @@ -72,7 +73,7 @@ module.exports.getBaseKarmaConfig = function() {
scssPreprocessor: {
options: {
file: '',
data: `$${moduleName}-is-silent: false; ${mainScssContent}`,
data: `${brands.length ? `$o-brand: ${brands[0]};` : ''}$${moduleName}-is-silent: false; ${mainScssContent}`,
includePaths: [process.cwd(), path.join(process.cwd(), 'bower_components')]
}
},
Expand Down
34 changes: 21 additions & 13 deletions lib/tasks/test-sass-compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,30 @@ module.exports = function (cfg) {
config.cwd = config.cwd || process.cwd();

return files.getModuleBrands().then((brands) => {
const brandCompilationTests = brands.map(brand => {
return {
title: `Testing SCSS compilation for the ${brand} brand`,
task: () => compilationTest(config.cwd, { brand }),
skip: () => !files.getMainSassPath(config.cwd)
};
});

return [{
const silientModeTest = {
title: 'Testing SCSS compilation with silent mode on',
task: () => compilationTest(config.cwd, { silent: true }),
skip: () => !files.getMainSassPath(config.cwd)
}, {
title: 'Testing SCSS compilation with silent mode off',
task: () => compilationTest(config.cwd, { silent: false }),
skip: () => !files.getMainSassPath(config.cwd)
}, ...brandCompilationTests];
};

if (brands.length === 0) {
return [silientModeTest, {
title: 'Testing SCSS compilation with silent mode off',
task: () => compilationTest(config.cwd, { silent: false }),
skip: () => !files.getMainSassPath(config.cwd)
}];
}

return [silientModeTest, ...brands.map(brand => {
return {
title: `Testing SCSS compilation for the ${brand} brand`,
task: () => compilationTest(config.cwd, {
brand,
silent: false
}),
skip: () => !files.getMainSassPath(config.cwd)
};
})];
});
};

0 comments on commit 0b6455c

Please sign in to comment.