Skip to content

Instantly share code, notes, and snippets.

@Robdel12
Last active Nov 14, 2019
Embed
What would you like to do?
const PercyScript = require('@percy/script');
const fs = require('fs');
const path = require('path');
const directories = [
path.resolve(__dirname, '../src/components/elements'),
path.resolve(__dirname, '../src/components/patterns'),
path.resolve(__dirname, '../src/components/templates'),
];
let urls = [];
for (const directory of directories) {
fs.readdir(directory, async function(err, components) {
if (err) {
// eslint-disable-next-line
console.log('Unable to scan directory: ' + err);
}
for (const component of components) {
if (component.includes('.md') && component !== 'README.md') {
const name = component.replace('.md', '');
urls.push(`http://localhost:7070/#!/${name}`);
}
}
});
}
PercyScript.run(async (page, percySnapshot) => {
for (const url of urls) {
await page.goto(url);
await percySnapshot(name);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment