From 9deb222620e387ee7bc625efa72fb474322c4b05 Mon Sep 17 00:00:00 2001 From: Nick Colley Date: Thu, 8 Mar 2018 13:31:08 +0000 Subject: [PATCH 1/3] Add test to confirm individual components compile Iterate through all components and build their Sass, checking for build errors. --- package.json | 3 +- ...heck-individual-components-compile.test.js | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tasks/gulp/__tests__/check-individual-components-compile.test.js diff --git a/package.json b/package.json index cd833af2d4..3c6f4f82a4 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "build:dist": "node bin/check-nvmrc.js && gulp build:dist --destination 'dist' && npm run test:build:dist", "test": "standard && gulp test && npm run test:app && npm run test:components && npm run test:generate:readme", "test:app": "jest app/__tests__/app.test.js --forceExit # express server fails to end process", - "test:components": "jest src/", + "test:components": "jest src/ && jest tasks/gulp/__tests__/check-individual-components-compile.test.js", "test:generate:readme": "jest tasks/gulp/__tests__/check-generate-readme.test.js", "test:build:packages": "jest tasks/gulp/__tests__/after-build-packages.test.js", "test:build:dist": "jest tasks/gulp/__tests__/after-build-dist.test.js" @@ -57,6 +57,7 @@ "js-yaml": "^3.10.0", "lerna": "^2.3.1", "merge-stream": "^1.0.1", + "node-sass": "^4.7.2", "nodemon": "^1.12.1", "oldie": "^1.3.0", "postcss-normalize": "^3.0.0", diff --git a/tasks/gulp/__tests__/check-individual-components-compile.test.js b/tasks/gulp/__tests__/check-individual-components-compile.test.js new file mode 100644 index 0000000000..563393ca18 --- /dev/null +++ b/tasks/gulp/__tests__/check-individual-components-compile.test.js @@ -0,0 +1,37 @@ +/* eslint-env jest */ + +const path = require('path') + +const sass = require('node-sass') + +const lib = require('../../../lib/file-helper') +const configPaths = require('../../../config/paths.json') + +const sassRender = (options) => { + return new Promise((resolve, reject) => { + sass.render(options, (error, result) => { + if (error) { + return reject(error) + } + return resolve(result) + }) + }) +} + +describe('Individual components', () => { + it('should compile individual scss files without throwing exceptions', done => { + const componentNames = lib.SrcFilteredComponentList.slice() + + const getSassRenders = () => { + return componentNames.map(name => { + const filePath = path.join(configPaths.src, name, `_${name}.scss`) + return sassRender({ file: filePath }) + }) + } + + Promise + .all(getSassRenders()) + .then(() => { done() }) + .catch(error => { throw error }) + }) +}) From 24c01dae7b3b1a918e6d09c61fc3412073da8b38 Mon Sep 17 00:00:00 2001 From: Nick Colley Date: Thu, 8 Mar 2018 13:35:34 +0000 Subject: [PATCH 2/3] Fix footer component not relying on common globals --- src/footer/_footer.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/footer/_footer.scss b/src/footer/_footer.scss index 7163aafeb3..e503294e43 100644 --- a/src/footer/_footer.scss +++ b/src/footer/_footer.scss @@ -1,3 +1,5 @@ +@import "../globals/common"; + @include govuk-exports("footer") { $govuk-footer-background: $govuk-grey-3; From 1f6892b67c244419daa6f263a0dfdadcc27fa403 Mon Sep 17 00:00:00 2001 From: Nick Colley Date: Thu, 8 Mar 2018 13:36:44 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70015db096..ac0b90f572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ Internal: (PR [#574](https://github.com/alphagov/govuk-frontend/pull/574)) - Ensure render function does not have undefined object (PR [#587](https://github.com/alphagov/govuk-frontend/pull/587)) +- Fix components relying on global builds + (PR [#588](https://github.com/alphagov/govuk-frontend/pull/588)) ## 0.0.25-alpha (Breaking release)