fix(e2e): cleans up the screenshot filenames, skips comparison when unable to download screenshot

This commit is contained in:
Robert Messerle
2016-03-20 22:45:01 -07:00
committed by Jeremy Elbourn
parent 7fa7fa7bcc
commit e7beecdf65
2 changed files with 22 additions and 5 deletions
+22 -5
View File
@@ -14,13 +14,32 @@ const LFS_BASE_URL = 'https://media.githubusercontent.com/media/angular/material
* be added to git.
*/
class Screenshot {
/**
* The filename used to store the screenshot
* @returns {string}
*/
get filename() {
return this.id
.toLowerCase()
.replace(/[ :\/]/g, '_')
.replace(/[^/a-z0-9_]+/g, '')
+ '.screenshot.png';
}
/**
* The full path to the screenshot
* @returns {string}
*/
get path() {
return path.resolve(__dirname, '..', 'screenshots', this.filename);
}
/**
* @param {string} id A unique identifier used for the screenshot
*/
constructor(id) {
this.id = id;
this.path = path.resolve(__dirname, '..', 'screenshots', id + '.screenshot.png');
this.url = `${LFS_BASE_URL}/${SHA}/screenshots/${encodeURIComponent(id)}.screenshot.png`;
this.url = `${LFS_BASE_URL}/${SHA}/screenshots/${this.filename}`;
browser.takeScreenshot().then(png => this.storeScreenshot(png));
}
@@ -63,9 +82,7 @@ class Screenshot {
console.info('[STATUS] Screenshot has not changed');
}
} catch (e) {
console.error(`[ERROR] `, e);
this.overwriteExistingScreenshot();
throw e;
console.info('[STATUS] Unable to manually load screenshot, skipping comparison');
}
}

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB