Skip to content

Commit e7beecd

Browse files
robertmesserlejelbourn
authored andcommitted
fix(e2e): cleans up the screenshot filenames, skips comparison when unable to download screenshot
1 parent 7fa7fa7 commit e7beecd

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

e2e/_screenshot.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,32 @@ const LFS_BASE_URL = 'https://media.githubusercontent.com/media/angular/material
1414
* be added to git.
1515
*/
1616
class Screenshot {
17+
/**
18+
* The filename used to store the screenshot
19+
* @returns {string}
20+
*/
21+
get filename() {
22+
return this.id
23+
.toLowerCase()
24+
.replace(/[ :\/]/g, '_')
25+
.replace(/[^/a-z0-9_]+/g, '')
26+
+ '.screenshot.png';
27+
}
28+
29+
/**
30+
* The full path to the screenshot
31+
* @returns {string}
32+
*/
33+
get path() {
34+
return path.resolve(__dirname, '..', 'screenshots', this.filename);
35+
}
36+
1737
/**
1838
* @param {string} id A unique identifier used for the screenshot
1939
*/
2040
constructor(id) {
2141
this.id = id;
22-
this.path = path.resolve(__dirname, '..', 'screenshots', id + '.screenshot.png');
23-
this.url = `${LFS_BASE_URL}/${SHA}/screenshots/${encodeURIComponent(id)}.screenshot.png`;
42+
this.url = `${LFS_BASE_URL}/${SHA}/screenshots/${this.filename}`;
2443
browser.takeScreenshot().then(png => this.storeScreenshot(png));
2544
}
2645

@@ -63,9 +82,7 @@ class Screenshot {
6382
console.info('[STATUS] Screenshot has not changed');
6483
}
6584
} catch (e) {
66-
console.error(`[ERROR] `, e);
67-
this.overwriteExistingScreenshot();
68-
throw e;
85+
console.info('[STATUS] Unable to manually load screenshot, skipping comparison');
6986
}
7087
}
7188

0 commit comments

Comments
 (0)