@brightspace-ui/testing 1.24.3 → 1.25.0
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.25.0",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/testing.git",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "npm run lint:eslint && npm run lint:style",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"test:browser:other": "npx d2l-test-runner --files \"./test/browser/**/*.test.js\"",
|
|
15
15
|
"test:browser:ctor": "npx d2l-test-runner --config ./test/browser/ctor.config.js",
|
|
16
16
|
"test:server": "mocha './test/server/**/*.test.js'",
|
|
17
|
-
"test:vdiff": "npx d2l-test-runner vdiff --config ./test/browser/vdiff.config.js"
|
|
17
|
+
"test:vdiff": "npx d2l-test-runner vdiff $npm_config_sub --config ./test/browser/vdiff.config.js"
|
|
18
18
|
},
|
|
19
19
|
"bin": {
|
|
20
20
|
"d2l-test-runner": "./bin/d2l-test-runner.js",
|
package/src/server/report/app.js
CHANGED
|
@@ -253,6 +253,23 @@ class App extends LitElement {
|
|
|
253
253
|
<ul>${browserDiffs}</ul>
|
|
254
254
|
</div>
|
|
255
255
|
` : nothing;
|
|
256
|
+
|
|
257
|
+
const systemDiffs = Object.entries(data.system).reduce((acc, [k, v]) => {
|
|
258
|
+
const previous = data.system.previous[k] || 'unknown';
|
|
259
|
+
if (k === 'previous' || previous === v) {
|
|
260
|
+
return acc;
|
|
261
|
+
}
|
|
262
|
+
return acc.push(html`
|
|
263
|
+
<li>${k}: <strong>${data.system.previous[k]}</strong> to <strong>${v}</strong></li>
|
|
264
|
+
`) && acc;
|
|
265
|
+
}, []);
|
|
266
|
+
const systemDiffInfo = systemDiffs.length ? html`
|
|
267
|
+
<div class="browser-diff">
|
|
268
|
+
<div class="browser-diff-title">System Changes</div>
|
|
269
|
+
<ul>${systemDiffs}</ul>
|
|
270
|
+
</div>
|
|
271
|
+
` : nothing;
|
|
272
|
+
|
|
256
273
|
const byteDiffFilter = (data.numByteDiff > 0) ? html`
|
|
257
274
|
<fieldset>
|
|
258
275
|
<legend>Byte Diffs</legend>
|
|
@@ -271,6 +288,7 @@ class App extends LitElement {
|
|
|
271
288
|
${byteDiffFilter}
|
|
272
289
|
${browserFilter}
|
|
273
290
|
${browserDiffInfo}
|
|
291
|
+
${systemDiffInfo}
|
|
274
292
|
`;
|
|
275
293
|
|
|
276
294
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as os from 'node:os';
|
|
1
2
|
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
3
|
import { dirname, join } from 'node:path';
|
|
3
4
|
import { env } from 'node:process';
|
|
@@ -59,14 +60,24 @@ function createData(rootDir, updateGoldens, sessions) {
|
|
|
59
60
|
});
|
|
60
61
|
});
|
|
61
62
|
|
|
63
|
+
const system = {
|
|
64
|
+
platform: os.platform(),
|
|
65
|
+
release: os.release(),
|
|
66
|
+
arch: os.arch()
|
|
67
|
+
};
|
|
68
|
+
|
|
62
69
|
if (isCI || updateGoldens) {
|
|
63
70
|
metadata.browsers = Array.from(browsers.values()).map(b => {
|
|
64
71
|
return { name: b.name, version: b.version };
|
|
65
72
|
});
|
|
73
|
+
metadata.system = system;
|
|
66
74
|
writeFileSync(metadataPath, `${JSON.stringify(metadata, undefined, '\t')}\n`);
|
|
67
75
|
}
|
|
68
76
|
|
|
69
|
-
|
|
77
|
+
const { previous: gc, ...previous } = metadata.system;
|
|
78
|
+
system.previous = previous;
|
|
79
|
+
|
|
80
|
+
return { browsers, files, numByteDiff, numFailed, numTests, system };
|
|
70
81
|
|
|
71
82
|
}
|
|
72
83
|
|
package/src/server/wtr-config.js
CHANGED
|
@@ -62,45 +62,12 @@ export const DEFAULT_VDIFF_SLOW = 500;
|
|
|
62
62
|
|
|
63
63
|
export class WTRConfig {
|
|
64
64
|
|
|
65
|
-
#cliArgs;
|
|
66
|
-
#requestedBrowsers;
|
|
67
|
-
|
|
68
65
|
constructor(cliArgs) {
|
|
69
66
|
this.#cliArgs = cliArgs || {};
|
|
70
67
|
this.#cliArgs.group ??= 'test';
|
|
71
68
|
const requestedBrowsers = ALLOWED_BROWSERS.filter(b => cliArgs?.[b]);
|
|
72
69
|
this.#requestedBrowsers = requestedBrowsers.length && requestedBrowsers;
|
|
73
70
|
}
|
|
74
|
-
|
|
75
|
-
get #defaultConfig() {
|
|
76
|
-
return {
|
|
77
|
-
browserStartTimeout: 60 * 1000,
|
|
78
|
-
groups: [],
|
|
79
|
-
nodeResolve: {
|
|
80
|
-
exportConditions: ['default']
|
|
81
|
-
},
|
|
82
|
-
testRunnerHtml: testFramework =>
|
|
83
|
-
`<!DOCTYPE html>
|
|
84
|
-
<html lang="en" data-timezone='${TIMEZONE}'>
|
|
85
|
-
<body>
|
|
86
|
-
${TEST_PAGE}
|
|
87
|
-
${SUPPRESS_RESIZE_OBSERVER_ERRORS}
|
|
88
|
-
<script type="module" src="${testFramework}"></script>
|
|
89
|
-
</body>
|
|
90
|
-
</html>`,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
get #pattern() {
|
|
95
|
-
const files = [ this.#cliArgs.files || this.pattern(this.#cliArgs.group), '!**/node_modules/**/*' ].flat();
|
|
96
|
-
|
|
97
|
-
if (this.#cliArgs.filter) {
|
|
98
|
-
return this.#filterFiles(files);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return files;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
71
|
get visualDiffGroup() {
|
|
105
72
|
return {
|
|
106
73
|
name: 'vdiff',
|
|
@@ -162,56 +129,6 @@ export class WTRConfig {
|
|
|
162
129
|
</html>`
|
|
163
130
|
};
|
|
164
131
|
}
|
|
165
|
-
|
|
166
|
-
#filterFiles(files) {
|
|
167
|
-
return this.#cliArgs.filter.map(filterStr => {
|
|
168
|
-
// replace everything after the last forward slash
|
|
169
|
-
return files
|
|
170
|
-
.filter(f => !f.startsWith('!')) // don't filter exclusions
|
|
171
|
-
.map(f => f.replace(/[^/]*$/, fileGlob => {
|
|
172
|
-
// create a new glob for each wildcard
|
|
173
|
-
const fileGlobs = Array.from(fileGlob.matchAll(/(?<!\*)\*(?!\*)/g)).map(({ index }) => {
|
|
174
|
-
const arr = fileGlob.split('');
|
|
175
|
-
arr.splice(index, 1, filterStr);
|
|
176
|
-
return arr.join('');
|
|
177
|
-
});
|
|
178
|
-
return `+(${fileGlobs.join('|') || fileGlob})`;
|
|
179
|
-
}));
|
|
180
|
-
})
|
|
181
|
-
.flat()
|
|
182
|
-
.concat(files.filter(f => f.startsWith('!')));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#getMochaConfig(group, slowConfig, timeoutConfig) {
|
|
186
|
-
const {
|
|
187
|
-
timeout = timeoutConfig,
|
|
188
|
-
grep,
|
|
189
|
-
open,
|
|
190
|
-
slow = slowConfig,
|
|
191
|
-
watch
|
|
192
|
-
} = this.#cliArgs;
|
|
193
|
-
|
|
194
|
-
if (typeof timeout !== 'undefined' && typeof timeout !== 'number') throw new TypeError('timeout must be a number');
|
|
195
|
-
if (typeof slow !== 'undefined' && typeof slow !== 'number') throw new TypeError('slow must be a number');
|
|
196
|
-
|
|
197
|
-
const config = {};
|
|
198
|
-
|
|
199
|
-
if (timeout) {
|
|
200
|
-
config.timeout = String(timeout);
|
|
201
|
-
} else if (group === 'vdiff') {
|
|
202
|
-
config.timeout = '5000';
|
|
203
|
-
}
|
|
204
|
-
if (open || watch) config.timeout = '0';
|
|
205
|
-
if (grep) config.grep = grep;
|
|
206
|
-
if (slow) {
|
|
207
|
-
config.slow = String(slow);
|
|
208
|
-
} else if (group === 'vdiff') {
|
|
209
|
-
config.slow = String(DEFAULT_VDIFF_SLOW);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return Object.keys(config).length && { testFramework: { config } };
|
|
213
|
-
}
|
|
214
|
-
|
|
215
132
|
create({
|
|
216
133
|
pattern = DEFAULT_PATTERN,
|
|
217
134
|
slow,
|
|
@@ -288,7 +205,6 @@ export class WTRConfig {
|
|
|
288
205
|
|
|
289
206
|
return config;
|
|
290
207
|
}
|
|
291
|
-
|
|
292
208
|
getBrowsers(browsers, deviceScaleFactor) {
|
|
293
209
|
browsers = (this.#requestedBrowsers || browsers || DEFAULT_BROWSERS).map(b => BROWSER_MAP[b] || BROWSER_MAP.chrome);
|
|
294
210
|
|
|
@@ -306,5 +222,86 @@ export class WTRConfig {
|
|
|
306
222
|
}
|
|
307
223
|
}));
|
|
308
224
|
}
|
|
225
|
+
#cliArgs;
|
|
226
|
+
|
|
227
|
+
#requestedBrowsers;
|
|
228
|
+
|
|
229
|
+
get #defaultConfig() {
|
|
230
|
+
return {
|
|
231
|
+
browserStartTimeout: 60 * 1000,
|
|
232
|
+
groups: [],
|
|
233
|
+
nodeResolve: {
|
|
234
|
+
exportConditions: ['default']
|
|
235
|
+
},
|
|
236
|
+
testRunnerHtml: testFramework =>
|
|
237
|
+
`<!DOCTYPE html>
|
|
238
|
+
<html lang="en" data-timezone='${TIMEZONE}'>
|
|
239
|
+
<body>
|
|
240
|
+
${TEST_PAGE}
|
|
241
|
+
${SUPPRESS_RESIZE_OBSERVER_ERRORS}
|
|
242
|
+
<script type="module" src="${testFramework}"></script>
|
|
243
|
+
</body>
|
|
244
|
+
</html>`,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
get #pattern() {
|
|
249
|
+
const files = [ this.#cliArgs.files || this.pattern(this.#cliArgs.group), '!**/node_modules/**/*' ].flat();
|
|
250
|
+
|
|
251
|
+
if (this.#cliArgs.filter) {
|
|
252
|
+
return this.#filterFiles(files);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return files;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
#filterFiles(files) {
|
|
259
|
+
return this.#cliArgs.filter.map(filterStr => {
|
|
260
|
+
// replace everything after the last forward slash
|
|
261
|
+
return files
|
|
262
|
+
.filter(f => !f.startsWith('!')) // don't filter exclusions
|
|
263
|
+
.map(f => f.replace(/[^/]*$/, fileGlob => {
|
|
264
|
+
// create a new glob for each wildcard
|
|
265
|
+
const fileGlobs = Array.from(fileGlob.matchAll(/(?<!\*)\*(?!\*)/g)).map(({ index }) => {
|
|
266
|
+
const arr = fileGlob.split('');
|
|
267
|
+
arr.splice(index, 1, filterStr);
|
|
268
|
+
return arr.join('');
|
|
269
|
+
});
|
|
270
|
+
return `+(${fileGlobs.join('|') || fileGlob})`;
|
|
271
|
+
}));
|
|
272
|
+
})
|
|
273
|
+
.flat()
|
|
274
|
+
.concat(files.filter(f => f.startsWith('!')));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
#getMochaConfig(group, slowConfig, timeoutConfig) {
|
|
278
|
+
const {
|
|
279
|
+
timeout = timeoutConfig,
|
|
280
|
+
grep,
|
|
281
|
+
open,
|
|
282
|
+
slow = slowConfig,
|
|
283
|
+
watch
|
|
284
|
+
} = this.#cliArgs;
|
|
285
|
+
|
|
286
|
+
if (typeof timeout !== 'undefined' && typeof timeout !== 'number') throw new TypeError('timeout must be a number');
|
|
287
|
+
if (typeof slow !== 'undefined' && typeof slow !== 'number') throw new TypeError('slow must be a number');
|
|
288
|
+
|
|
289
|
+
const config = {};
|
|
290
|
+
|
|
291
|
+
if (timeout) {
|
|
292
|
+
config.timeout = String(timeout);
|
|
293
|
+
} else if (group === 'vdiff') {
|
|
294
|
+
config.timeout = '5000';
|
|
295
|
+
}
|
|
296
|
+
if (open || watch) config.timeout = '0';
|
|
297
|
+
if (grep) config.grep = grep;
|
|
298
|
+
if (slow) {
|
|
299
|
+
config.slow = String(slow);
|
|
300
|
+
} else if (group === 'vdiff') {
|
|
301
|
+
config.slow = String(DEFAULT_VDIFF_SLOW);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return Object.keys(config).length && { testFramework: { config } };
|
|
305
|
+
}
|
|
309
306
|
|
|
310
307
|
}
|