@brightspace-ui/testing 1.12.3 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@brightspace-ui/testing",
|
|
3
3
|
"description": "Utilities for testing front-end components and applications",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.13.1",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/testing.git",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "eslint . --ext .js",
|
|
@@ -177,7 +177,7 @@ function renderResult(resultData, options) {
|
|
|
177
177
|
newPart = html`<div class="result-graphic padding">${ICON_TADA}<p>Hooray! No changes here.</p></div>`;
|
|
178
178
|
} else if (!resultData.info.diff && resultData.info.pixelsDiff === 0) {
|
|
179
179
|
newPart = html`<div class="result-graphic padding">${ICON_BYTES}
|
|
180
|
-
<p>No pixels have changed, but the
|
|
180
|
+
<p>No pixels have changed, but the bytes are different.</p>
|
|
181
181
|
<p class="details">
|
|
182
182
|
Golden size: ${resultData.info.golden.byteSize} bytes<br />
|
|
183
183
|
New size: ${resultData.info.new.byteSize} bytes
|
|
@@ -197,7 +197,8 @@ export function visualDiff({ updateGoldens = false, runSubset = false } = {}) {
|
|
|
197
197
|
|
|
198
198
|
const rootLength = join(rootDir, PATHS.VDIFF_ROOT).length + 1;
|
|
199
199
|
|
|
200
|
-
const
|
|
200
|
+
const screenshotFileBuffer = await readFile(screenshotFileName);
|
|
201
|
+
const screenshotImage = PNG.sync.read(screenshotFileBuffer);
|
|
201
202
|
setTestInfo(session, payload.name, {
|
|
202
203
|
slowDuration: payload.slowDuration,
|
|
203
204
|
new: {
|
|
@@ -217,7 +218,8 @@ export function visualDiff({ updateGoldens = false, runSubset = false } = {}) {
|
|
|
217
218
|
return { pass: false, message: 'No golden exists. Use the "--golden" CLI flag to re-run and re-generate goldens.' };
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
const
|
|
221
|
+
const goldenFileBuffer = await readFile(goldenFileName);
|
|
222
|
+
const goldenImage = PNG.sync.read(goldenFileBuffer);
|
|
221
223
|
setTestInfo(session, payload.name, {
|
|
222
224
|
golden: {
|
|
223
225
|
height: goldenImage.height,
|
|
@@ -227,6 +229,14 @@ export function visualDiff({ updateGoldens = false, runSubset = false } = {}) {
|
|
|
227
229
|
});
|
|
228
230
|
|
|
229
231
|
if (screenshotImage.width === goldenImage.width && screenshotImage.height === goldenImage.height) {
|
|
232
|
+
const goldenSize = (await stat(goldenFileName)).size;
|
|
233
|
+
const screenshotSize = (await stat(screenshotFileName)).size;
|
|
234
|
+
if (goldenSize === screenshotSize && screenshotFileBuffer.equals(goldenFileBuffer)) {
|
|
235
|
+
const success = await tryMoveFile(screenshotFileName, passFileName);
|
|
236
|
+
if (!success) return { pass: false, message: 'Problem moving file to "pass" directory.' };
|
|
237
|
+
return { pass: true };
|
|
238
|
+
}
|
|
239
|
+
|
|
230
240
|
const diff = new PNG({ width: screenshotImage.width, height: screenshotImage.height });
|
|
231
241
|
const pixelsDiff = pixelmatch(
|
|
232
242
|
screenshotImage.data, goldenImage.data, diff.data, screenshotImage.width, screenshotImage.height, { diffMask: true, threshold: DEFAULT_TOLERANCE }
|
|
@@ -243,25 +253,17 @@ export function visualDiff({ updateGoldens = false, runSubset = false } = {}) {
|
|
|
243
253
|
await writeFile(`${screenshotFile}-diff.png`, PNG.sync.write(diff));
|
|
244
254
|
return { pass: false, message: `Image does not match golden. ${pixelsDiff} pixels are different.` };
|
|
245
255
|
} else {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
pixelsDiff
|
|
258
|
-
});
|
|
259
|
-
return { pass: false, message: 'Image diff is clean but the images do not have the same byte size.' };
|
|
260
|
-
} else {
|
|
261
|
-
const success = await tryMoveFile(screenshotFileName, passFileName);
|
|
262
|
-
if (!success) return { pass: false, message: 'Problem moving file to "pass" directory.' };
|
|
263
|
-
return { pass: true };
|
|
264
|
-
}
|
|
256
|
+
setTestInfo(session, payload.name, {
|
|
257
|
+
golden: {
|
|
258
|
+
byteSize: goldenSize
|
|
259
|
+
},
|
|
260
|
+
new: {
|
|
261
|
+
path: `${screenshotFile.substring(rootLength)}.png`,
|
|
262
|
+
byteSize: screenshotSize
|
|
263
|
+
},
|
|
264
|
+
pixelsDiff
|
|
265
|
+
});
|
|
266
|
+
return { pass: false, message: 'Image diff is clean but the images do not have the same bytes.' };
|
|
265
267
|
}
|
|
266
268
|
} else {
|
|
267
269
|
return { resizeRequired: true };
|
package/src/server/wtr-config.js
CHANGED
|
@@ -5,8 +5,6 @@ import { visualDiff } from './visual-diff-plugin.js';
|
|
|
5
5
|
import { visualDiffReporter } from './visual-diff-reporter.js';
|
|
6
6
|
|
|
7
7
|
const DEFAULT_PATTERN = type => `./test/**/*.${type}.js`;
|
|
8
|
-
const ALLOWED_BROWSERS = ['chrome', 'chromium', 'firefox', 'safari', 'webkit'];
|
|
9
|
-
const DEFAULT_BROWSERS = ['chromium', 'firefox', 'webkit'];
|
|
10
8
|
const BROWSER_MAP = {
|
|
11
9
|
chrome: 'chromium',
|
|
12
10
|
chromium: 'chromium',
|
|
@@ -14,6 +12,8 @@ const BROWSER_MAP = {
|
|
|
14
12
|
safari: 'webkit',
|
|
15
13
|
webkit: 'webkit'
|
|
16
14
|
};
|
|
15
|
+
const ALLOWED_BROWSERS = Object.keys(BROWSER_MAP);
|
|
16
|
+
const DEFAULT_BROWSERS = [...new Set(Object.values(BROWSER_MAP))];
|
|
17
17
|
const TIMEZONE = '{"name":"Canada - Toronto","identifier":"America/Toronto"}';
|
|
18
18
|
const FONT_ASSETS = 'https://s.brightspace.com/lib/fonts/0.6.0/assets/';
|
|
19
19
|
const SUPPRESS_RESIZE_OBSERVER_ERRORS = `
|
|
@@ -71,7 +71,7 @@ export class WTRConfig {
|
|
|
71
71
|
return {
|
|
72
72
|
name: 'vdiff',
|
|
73
73
|
files: this.#pattern,
|
|
74
|
-
browsers: [
|
|
74
|
+
browsers: [BROWSER_MAP.chrome],
|
|
75
75
|
testRunnerHtml: testFramework =>
|
|
76
76
|
`<!DOCTYPE html>
|
|
77
77
|
<html lang="en" data-timezone='${TIMEZONE}'>
|
|
@@ -249,18 +249,19 @@ export class WTRConfig {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
getBrowsers(browsers) {
|
|
252
|
-
browsers = (this.#requestedBrowsers || browsers || DEFAULT_BROWSERS).map(b => BROWSER_MAP[b] ||
|
|
252
|
+
browsers = (this.#requestedBrowsers || browsers || DEFAULT_BROWSERS).map(b => BROWSER_MAP[b] || BROWSER_MAP.chrome);
|
|
253
253
|
|
|
254
254
|
if (!Array.isArray(browsers)) throw new TypeError('browsers must be an array');
|
|
255
255
|
|
|
256
256
|
return [...new Set(browsers)].map((b) => playwrightLauncher({
|
|
257
|
-
concurrency: b ===
|
|
257
|
+
concurrency: b === BROWSER_MAP.firefox || this.#cliArgs.open ? 1 : undefined, // focus in Firefox unreliable if concurrency > 1 (https://github.com/modernweb-dev/web/issues/238)
|
|
258
258
|
product: b,
|
|
259
259
|
createBrowserContext: ({ browser }) => browser.newContext({ deviceScaleFactor: 2, reducedMotion: 'reduce' }),
|
|
260
260
|
launchOptions: {
|
|
261
261
|
headless: !this.#cliArgs.open,
|
|
262
262
|
devtools: false,
|
|
263
|
-
slowMo: this.#cliArgs.slowmo || 0
|
|
263
|
+
slowMo: this.#cliArgs.slowmo || 0,
|
|
264
|
+
args: b === BROWSER_MAP.chrome ? ['--disable-gpu-rasterization'] : []
|
|
264
265
|
}
|
|
265
266
|
}));
|
|
266
267
|
}
|