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

Commit

Permalink
do not run sass compilation test if there is no main sass file
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeChampion committed Jun 17, 2021
1 parent 4f8c752 commit 5f36fcc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/tasks/test-sass-compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ const ListrRenderer = require('../helpers/listr-renderer');
const isCI = require('is-ci');
const { camelCase } = require('lodash');
const ftSass = require('@financial-times/sass');
const denodeify = require('util').promisify;
const fsOpen = denodeify(require('fs').open);
const { readFile } = require('fs/promises');
const execa = require('execa');

const fileExists = file => fsOpen(file, 'r').then(() => true).catch(() => false);
async function compilationTest(cwd, { silent, brand } = {
silent: false,
brand: false
Expand Down Expand Up @@ -119,6 +122,9 @@ module.exports = function (cfg) {
concurrent: true
});
},
skip: () => !files.getMainSassPath(config.cwd)
skip: async () => {
const exists = await fileExists(await files.getMainSassPath(config.cwd));
return !exists;
}
};
};
18 changes: 18 additions & 0 deletions test/integration/test/test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ describe('obt test', function () {
}
});
});

describe('with no Sass', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.22';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('passes', async function () {
try {
await execa(obt, ['test']);
} catch (error) {
throw new Error(`Test command failed: ${error}`);
}
});
});
});

});

0 comments on commit 5f36fcc

Please sign in to comment.