Last active
November 13, 2019 19:13
-
-
Save Robdel12/99783930a16272ac4d887123b6aae14b 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 = [ | |
{ | |
type: "Element", | |
path: path.resolve(__dirname, "src/components/elements") | |
}, | |
{ | |
type: "Pattern", | |
path: path.resolve(__dirname, "src/components/patterns") | |
}, | |
{ | |
type: "Template", | |
path: path.resolve(__dirname, "src/components/templates") | |
} | |
]; | |
PercyScript.run(async (page, percySnapshot) => { | |
for (const directory of directories) { | |
fs.readdir(directory.path, 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(".vue")) { | |
const name = component.replace(".vue", ""); | |
await page.goto( | |
`http://localhost:7070/#/Components/${directory.type}s/${name}` | |
); | |
// maybe consider a wait here to ensure the page is settled before snapshoting | |
await percySnapshot(name); | |
} | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment