Skip to content

Commit

Permalink
fix(@bolt/build-tools,@bolt/components-icons): move clean icon task t…
Browse files Browse the repository at this point in the history
…o be run after all the tests
  • Loading branch information
adamszalapski committed Mar 11, 2019
1 parent c501be3 commit 863f91d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions jest-global-setup.js
Expand Up @@ -18,11 +18,11 @@ module.exports = async function globalSetup() {
const existingIconsDir =
typeof config.iconDir !== 'undefined' ? config.iconDir : [];

config.iconDir = [...existingIconsDir, path.join(__dirname, './test/svg')];
config.iconDir = [...existingIconsDir, path.join(__dirname, './test/jest-test-svgs')];

await buildPrep(); // Generate folders, manifest data, etc needed for Twig renderer
await imageTasks.processImages(); // process image fixtures used by any tests
await iconTasks.build(); // process icons used by any task
await iconTasks.build(); // process icons used by any tests

await setupDevServer({
command: `node server/testing-server`,
Expand Down
9 changes: 9 additions & 0 deletions jest-global-teardown.js
Expand Up @@ -3,12 +3,21 @@ const rimraf = require('rimraf');
const path = require('path');

const { teardown: teardownDevServer } = require('jest-dev-server');
const { getConfig } = require('@bolt/build-tools/utils/config-store');
const iconTasks = require('@bolt/build-tools/tasks/icon-tasks');

const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');

module.exports = async function() {
// close the browser instance
await global.__BROWSER_GLOBAL__.close();
const config = await getConfig();

config.iconDir = config.iconDir.filter(
item => !item.includes('test/jest-test-svgs'),
);

await iconTasks.build(); // cleaning icons after all tests
await teardownDevServer();

// clean-up the wsEndpoint file
Expand Down
27 changes: 9 additions & 18 deletions packages/build-tools/tasks/icon-tasks.js
Expand Up @@ -302,25 +302,16 @@ async function build() {
.map(icon => `export * from './icons/${icon.id}';`); // building up `export` lines
allExports.push(''); // Adding empty item to end of array so file has empty line at bottom to conform to `.editorconfig`

return new Promise(async (resolve, reject) => {
await generateFile(icons)
.then(output => {
fs.outputFile(
path.join(rootDir, 'src', 'index.js'),
allExports.join('\n'),
'utf-8',
);

if (config.verbosity > 2) {
log.dim(`Built ${iconPaths.length} icons.`);
}
await fs.outputFile(
path.join(rootDir, 'src', 'index.js'),
allExports.join('\n'),
'utf-8',
);
await generateFile(icons);

resolve(output);
})
.catch(error => {
reject(error);
});
});
if (config.verbosity > 2) {
log.dim(`Built ${iconPaths.length} icons.`);
}
} catch (error) {
iconSpinner.fail(
chalk.red(
Expand Down
3 changes: 0 additions & 3 deletions packages/components/bolt-icons/__tests__/icons.js
@@ -1,8 +1,6 @@
import { fixture as html } from '@open-wc/testing-helpers';
import { render, stop as stopTwigRenderer } from '@bolt/twig-renderer';

const iconTasks = require('@bolt/build-tools/tasks/icon-tasks');

async function renderTwig(template, data) {
return await render(template, data, true);
}
Expand All @@ -13,7 +11,6 @@ describe('<bolt-icon> Component', async () => {
let page;

afterAll(async () => {
await iconTasks.build();
await stopTwigRenderer();
}, timeout);

Expand Down
File renamed without changes

0 comments on commit 863f91d

Please sign in to comment.