mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(e2e): cleans up the screenshot filenames, skips comparison when unable to download screenshot
This commit is contained in:
committed by
Jeremy Elbourn
parent
7fa7fa7bcc
commit
e7beecdf65
+22
-5
@@ -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 |
Reference in New Issue
Block a user