Add 2% tolerance to vector rendering tests

This commit is contained in:
Tim Schaub
2018-11-16 11:29:42 +01:00
parent 4a3dbb0e24
commit b3bcf7dac1
3 changed files with 16 additions and 7 deletions

View File

@@ -182,24 +182,30 @@ async function copyActualToExpected(entry) {
async function renderEach(page, entries, options) {
let fail = false;
for (const entry of entries) {
const config = await renderPage(page, entry, options);
const message = config.message !== undefined ? config.message : entry;
const tolerance = config.tolerance !== undefined ? config.tolerance : 0;
const {tolerance = 0, message = ''} = await renderPage(page, entry, options);
if (options.fix) {
await copyActualToExpected(entry);
continue;
}
const {error, mismatch} = await getScreenshotsMismatch(entry);
if (error) {
options.log.error(error);
fail = true;
continue;
}
let detail = `case ${entry}`;
if (message) {
detail = `${detail} (${message})`;
}
if (mismatch > tolerance) {
options.log.error(`checking '${message}': mismatch ${mismatch.toFixed(3)}`);
options.log.error(`${detail}': mismatch ${mismatch.toFixed(3)}`);
fail = true;
} else {
options.log.info(`checking '${message}': ok`);
options.log.info(`${detail}': ok`);
await touch(getPassFilePath(entry));
}
}