Allow tolerance to be passed to the render function
This commit is contained in:
@@ -18,4 +18,4 @@ new Map({
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
render('A single layer with a XZY source');
|
render({message: 'A single layer with a XZY source'});
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 7.4 KiB |
@@ -120,4 +120,4 @@ new Map({
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
render();
|
render({tolerance: 0.05});
|
||||||
|
|||||||
+8
-7
@@ -154,17 +154,17 @@ async function exposeRender(page) {
|
|||||||
|
|
||||||
async function renderPage(page, entry, options) {
|
async function renderPage(page, entry, options) {
|
||||||
const renderCalled = new Promise(resolve => {
|
const renderCalled = new Promise(resolve => {
|
||||||
handleRender = (message) => {
|
handleRender = (config) => {
|
||||||
handleRender = null;
|
handleRender = null;
|
||||||
resolve(message);
|
resolve(config || {});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
options.log.debug('navigating', entry);
|
options.log.debug('navigating', entry);
|
||||||
await page.goto(`http://${options.host}:${options.port}${getHref(entry)}`, {waitUntil: 'networkidle0'});
|
await page.goto(`http://${options.host}:${options.port}${getHref(entry)}`, {waitUntil: 'networkidle0'});
|
||||||
const message = await renderCalled;
|
const config = await renderCalled;
|
||||||
options.log.debug('screenshot', entry);
|
options.log.debug('screenshot', entry);
|
||||||
await page.screenshot({path: getActualScreenshotPath(entry)});
|
await page.screenshot({path: getActualScreenshotPath(entry)});
|
||||||
return message;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function touch(filepath) {
|
async function touch(filepath) {
|
||||||
@@ -182,8 +182,9 @@ async function copyActualToExpected(entry) {
|
|||||||
async function renderEach(page, entries, options) {
|
async function renderEach(page, entries, options) {
|
||||||
let fail = false;
|
let fail = false;
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
let message = await renderPage(page, entry, options);
|
const config = await renderPage(page, entry, options);
|
||||||
message = message !== undefined ? message : entry;
|
const message = config.message !== undefined ? config.message : entry;
|
||||||
|
const tolerance = config.tolerance !== undefined ? config.tolerance : 0;
|
||||||
if (options.fix) {
|
if (options.fix) {
|
||||||
await copyActualToExpected(entry);
|
await copyActualToExpected(entry);
|
||||||
continue;
|
continue;
|
||||||
@@ -194,7 +195,7 @@ async function renderEach(page, entries, options) {
|
|||||||
fail = true;
|
fail = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mismatch > 0) {
|
if (mismatch > tolerance) {
|
||||||
options.log.error(`checking '${message}': mismatch ${mismatch.toFixed(3)}`);
|
options.log.error(`checking '${message}': mismatch ${mismatch.toFixed(3)}`);
|
||||||
fail = true;
|
fail = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user