test: override -apple-system font with Roboto for visual testing

This commit is contained in:
Jason Dreyzehner 2018-02-14 18:28:00 -05:00
parent f080e6ca87
commit 90fa17d765
10 changed files with 13 additions and 1 deletions

View File

@ -11,7 +11,19 @@ const dir = join('test', 'latest', distribution);
// create dir if it doesn't exist
mkdirp(dir);
// Dark magic to override proprietary `-apple-system` font for visual regression
// screenshots (to avoid false alarms when testing on non-macOS systems) 🧙
const hackAppleSysFont =
"@font-face { font-family: -apple-system; src: local('Roboto'); }";
const jsToInjectCSSHack = `
var elem = document.createElement('style');
elem.innerHTML = "${hackAppleSysFont}";
document.body.appendChild(elem);
`;
export async function takeScreenshot(name: string) {
browser.executeScript(jsToInjectCSSHack);
const config = await browser.getProcessedConfig();
const deviceName = config['capabilities']['name'];
const pngData = await browser.takeScreenshot();

View File

@ -37,7 +37,7 @@
"test:coverage": "ng test --code-coverage",
"test:ci": "ng test --watch=false --code-coverage --no-progress",
"test:prettier": "prettier --list-different 'src/**/*.ts'",
"test:visual": "cd test && reg-cli latest approved diffs --report report.html --json report.json",
"test:visual": "cd test && reg-cli latest approved diffs --report report.html --json report.json --enableAntialias --thresholdRate 0.001",
"fix:prettier": "prettier 'src/**/*.ts' --write",
"fix:tslint": "tslint --fix --project . src/**/*.ts",
"e2e": "npm run ionic:build && npm run e2e:test",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 79 KiB