Open thesquaremedia opened 1 year ago
What I've done to achieve a similar effect:
allpages.js
, I put this in the backstop_data
folderexports.pages = [
"/blog/",
"/blog/some-post",
"/",
]
backstop-base-config.json
which includes your intended backstop config, not including scenarios, I put this in the backstop_data
foldergenerate-backstop.js
file which looks something like this, I put this in the backstop_data
folderconst pages = require('./allpages').pages;
const fs = require("fs");
const baseConfig = require('./backstop-base-config.json');
const scenarios = pages.map(page => {
// Remove leading and trailing slashes for the label
const label = page.replace(/^\//, "").replace(/\/$/, "");
return {
"label": label,
"referenceUrl": `https://www.referenceUrl.com${page}`,
"url": `https://www.stage.referenceUrl.com${page}`,
"hideSelectors": [],
"removeSelectors": [],
"selectors": ["body"],
"hideSelectors": [],
"delay": 500,
"misMatchThreshold" : 0.1,
};
});
const finalConfig = Object.assign(
{},
baseConfig,
{scenarios: scenarios}
);
fs.writeFileSync("../backstop.json", JSON.stringify(finalConfig, null, 4));
from there you can run
node generate-backstop
and generate a static backstop.json
in your root directory and then run npx backstop reference
or npx backstop test
You will probably need to adjust based on how you're scraping your own sitemap, but, this should be a way to do it.
im getting
TypeError: Cannot set properties of undefined (setting 'tempCompareConfigFileName')
when I set in the config filemodule.exports = getPaths();
within that function im attempting to build the config propertiesscenerios
being an array that gets paths push into through a for loop above before returning.return { "id": "prod_test", "viewports": [ { "name": "small", "width": 320, "height": 480 }, { "name": "medium", "width": 760, "height": 1024 }, { "name": "xlarge", "width": 1440, "height": 900 } ], "scenarios": scenarios , "paths": { "bitmaps_reference": "./backstop_data/bitmaps_reference", "bitmaps_test": "./backstop_data/bitmaps_test", "casper_scripts": "./backstop_data/casper_scripts", "html_report": "./backstop_data/html_report", "ci_report": "./backstop_data/ci_report" }, "engine": "puppeteer", "engineOptions": { "args": ["--no-sandbox"] }, "onBeforeScript": "puppet/onBefore.js", "asyncCaptureLimit": 5, "asyncCompareLimit": 50, "debug": false, "debugWindow": false };