@brightspace-ui/testing 1.1.0 → 1.3.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/README.md +5 -4
- package/package.json +1 -1
- package/src/browser/reset.js +8 -8
- package/src/server/wtr-config.js +15 -11
package/README.md
CHANGED
|
@@ -474,14 +474,15 @@ To capture the entire viewport, pass `document` as the target element to the ass
|
|
|
474
474
|
await expect(document).to.be.golden();
|
|
475
475
|
```
|
|
476
476
|
|
|
477
|
-
####
|
|
477
|
+
#### Turning Off Full Page Padding
|
|
478
478
|
|
|
479
|
-
|
|
479
|
+
By default, the page hosting vdiff fixtures has `38px` of padding. For fixtures which are meant to fill the entire page with no surrounding whitespace, the page padding can be disabled:
|
|
480
480
|
|
|
481
481
|
```javascript
|
|
482
|
-
|
|
483
|
-
|
|
482
|
+
await fixture(html`<fullscreen-elem></fullscreen-elem>`, {
|
|
483
|
+
pagePadding: false
|
|
484
484
|
});
|
|
485
|
+
await expect(document).to.be.golden();
|
|
485
486
|
```
|
|
486
487
|
|
|
487
488
|
#### Including Other Elements
|
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.3.0",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/testing.git",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "eslint . --ext .js",
|
package/src/browser/reset.js
CHANGED
|
@@ -2,7 +2,7 @@ import { emulateMedia, sendMouse, setViewport } from '@web/test-runner-commands'
|
|
|
2
2
|
import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js';
|
|
3
3
|
import { nextFrame } from '@open-wc/testing';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const DEFAULT_PAGE_PADDING = true,
|
|
6
6
|
DEFAULT_LANG = 'en',
|
|
7
7
|
DEFAULT_MATHJAX_RENDER_LATEX = false,
|
|
8
8
|
DEFAULT_MEDIA = 'screen',
|
|
@@ -12,7 +12,7 @@ const DEFAULT_FULLSCREEN = false,
|
|
|
12
12
|
const documentLocaleSettings = getDocumentLocaleSettings();
|
|
13
13
|
|
|
14
14
|
let
|
|
15
|
-
|
|
15
|
+
currentPagePadding = true,
|
|
16
16
|
currentMathjaxRenderLatex = DEFAULT_MATHJAX_RENDER_LATEX,
|
|
17
17
|
currentMedia = DEFAULT_MEDIA,
|
|
18
18
|
currentRtl = false,
|
|
@@ -34,7 +34,7 @@ export async function reset(opts = {}) {
|
|
|
34
34
|
height: DEFAULT_VIEWPORT_HEIGHT,
|
|
35
35
|
width: DEFAULT_VIEWPORT_WIDTH
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
pagePadding: DEFAULT_PAGE_PADDING,
|
|
38
38
|
media: DEFAULT_MEDIA
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -46,15 +46,15 @@ export async function reset(opts = {}) {
|
|
|
46
46
|
|
|
47
47
|
window.scroll(0, 0);
|
|
48
48
|
|
|
49
|
-
if (opts.
|
|
50
|
-
if (opts.
|
|
51
|
-
document.body.classList.add('
|
|
49
|
+
if (opts.pagePadding !== currentPagePadding) {
|
|
50
|
+
if (!opts.pagePadding) {
|
|
51
|
+
document.body.classList.add('no-padding');
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
document.body.classList.remove('
|
|
54
|
+
document.body.classList.remove('no-padding');
|
|
55
55
|
}
|
|
56
56
|
awaitNextFrame = true;
|
|
57
|
-
|
|
57
|
+
currentPagePadding = opts.pagePadding;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (shouldResetMouse) {
|
package/src/server/wtr-config.js
CHANGED
|
@@ -14,6 +14,15 @@ const BROWSER_MAP = {
|
|
|
14
14
|
safari: 'webkit',
|
|
15
15
|
webkit: 'webkit'
|
|
16
16
|
};
|
|
17
|
+
const SUPPRESS_RESIZE_OBSERVER_ERRORS = `
|
|
18
|
+
<script>
|
|
19
|
+
window.addEventListener('error', (err) => {
|
|
20
|
+
if (err.message.includes('ResizeObserver')) {
|
|
21
|
+
err.stopImmediatePropagation();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
`;
|
|
17
26
|
export const DEFAULT_VDIFF_SLOW = 500;
|
|
18
27
|
|
|
19
28
|
export class WTRConfig {
|
|
@@ -36,13 +45,7 @@ export class WTRConfig {
|
|
|
36
45
|
`<!DOCTYPE html>
|
|
37
46
|
<html lang="en">
|
|
38
47
|
<body>
|
|
39
|
-
|
|
40
|
-
window.addEventListener('error', (err) => {
|
|
41
|
-
if (err.message.includes('ResizeObserver')) {
|
|
42
|
-
err.stopImmediatePropagation();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
</script>
|
|
48
|
+
${SUPPRESS_RESIZE_OBSERVER_ERRORS}
|
|
46
49
|
<script type="module" src="${testFramework}"></script>
|
|
47
50
|
</body>
|
|
48
51
|
</html>`,
|
|
@@ -94,15 +97,16 @@ export class WTRConfig {
|
|
|
94
97
|
font-size: 0.95rem;
|
|
95
98
|
font-weight: 400;
|
|
96
99
|
line-height: 1.4rem;
|
|
97
|
-
|
|
100
|
+
margin: 0;
|
|
101
|
+
padding: 38px;
|
|
98
102
|
}
|
|
99
|
-
body.
|
|
100
|
-
|
|
101
|
-
inset: 0;
|
|
103
|
+
body.no-padding {
|
|
104
|
+
padding: 0;
|
|
102
105
|
}
|
|
103
106
|
</style>
|
|
104
107
|
</head>
|
|
105
108
|
<body>
|
|
109
|
+
${SUPPRESS_RESIZE_OBSERVER_ERRORS}
|
|
106
110
|
<script type="module" src="${testFramework}"></script>
|
|
107
111
|
</body>
|
|
108
112
|
</html>`
|