Skip to content

Commit

Permalink
fix(e2e): cleans up the screenshot filenames, skips comparison when u…
Browse files Browse the repository at this point in the history
…nable to download screenshot
  • Loading branch information
robertmesserle authored and jelbourn committed Mar 22, 2016
1 parent 7fa7fa7 commit e7beecd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions e2e/_screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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');
}
}

Expand Down
File renamed without changes

0 comments on commit e7beecd

Please sign in to comment.