pidgin/nest

f12f4f510651
[minor] tidy up of visual-diff
--- a/tools/visual-diff.js Wed Mar 20 04:12:58 2019 +0000
+++ b/tools/visual-diff.js Thu Mar 21 19:35:38 2019 +0000
@@ -1,7 +1,5 @@
-let config
-
try {
- config = require('./diff-config.json')
+ var config = require('./diff-config.json')
} catch (e) {
config = {}
}
@@ -33,12 +31,11 @@
tablet: Object.freeze({ width: 768, height: 4000 }),
massive: Object.freeze({ width: 1440, height: 4000 }),
})
-
+const viewportKeys = Object.keys(viewports)
const nonIdentical = []
;(async () => {
const stack = []
- const viewportKeys = Object.keys(viewports)
// Map the target pages
const pages = (await fetch_json(`${dir}/index.json`))
.map(u => u.uri)
@@ -47,6 +44,7 @@
console.log(`Diffing these pages:`)
+ // Populates stack with tests
for (const pagePath of pages) {
console.log('\t' + pagePath.trim().replace(dir, ''))
@@ -55,10 +53,12 @@
}
}
+ // Run tests
await differencify.launchBrowser({ timeout: 0 })
await concurrence(stack)
await differencify.cleanup()
+ // Output results
if (nonIdentical.length) {
console.log(`Pages that have changed:`)
console.log(
@@ -84,16 +84,13 @@
try {
await differencify
- .init({
- testName,
- timeout: 0,
- })
+ .init({ testName, timeout: 0 })
.newPage()
.setViewport(viewport)
.goto(url)
.wait(waitToScreenShotTime)
.screenshot()
- .toMatchSnapshot({ testName })
+ .toMatchSnapshot()
.result(result => {
if (!result) nonIdentical.push(`${viewportName} ${path}`)
})
@@ -122,7 +119,7 @@
}
/**
- *
+ * Creates a file safe string
* @param {string} str Possibly unsafe url
*/
function safeFileName(str) {
@@ -134,7 +131,7 @@
/**
* Handles concurrence
- * @param {Fucntion[]} stack The fucntions to be called
+ * @param {Function[]} stack The fucntions to be called
*/
function concurrence(stack) {
const er = e => console.error(e)