Last active
November 14, 2019 16:45
-
-
Save Robdel12/85025052e1917c191bb98b0253412a34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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