Skip to content

Commit 7f54ea5

Browse files
committed
test: fix more UTs
1 parent e6cde39 commit 7f54ea5

7 files changed

Lines changed: 127 additions & 3 deletions

File tree

packages/image-comparison-core/src/commands/__snapshots__/checkAppElement.test.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`checkAppElement > should always disable block out options for element screenshots 1`] = `
44
[
55
{
6+
"actualBase64Image": undefined,
67
"isNativeContext": true,
78
"isViewPortScreenshot": false,
89
"options": {
@@ -277,7 +278,7 @@ exports[`checkAppElement > should execute checkAppElement with basic options 2`]
277278
exports[`checkAppElement > should handle Android device correctly 1`] = `
278279
[
279280
{
280-
281+
"actualBase64Image": undefined,
281282
"isNativeContext": true,
282283
"isViewPortScreenshot": false,
283284
"options": {

packages/image-comparison-core/src/commands/__snapshots__/checkAppScreen.test.ts.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ exports[`checkAppScreen > should handle Android device correctly 1`] = `
379379
exports[`checkAppScreen > should handle Android device correctly 2`] = `
380380
[
381381
{
382+
"actualBase64Image": undefined,
382383
"isNativeContext": true,
383384
"isViewPortScreenshot": true,
384385
"options": {
@@ -654,7 +655,7 @@ exports[`checkAppScreen > should handle ignore regions and device blockouts 2`]
654655
exports[`checkAppScreen > should handle ignore regions and device blockouts 3`] = `
655656
[
656657
{
657-
658+
"actualBase64Image": undefined,
658659
"isNativeContext": true,
659660
"isViewPortScreenshot": true,
660661
"options": {
@@ -793,6 +794,7 @@ exports[`checkAppScreen > should handle ignore regions and device blockouts 3`]
793794
exports[`checkAppScreen > should merge compare options correctly 1`] = `
794795
[
795796
{
797+
"actualBase64Image": undefined,
796798
"isNativeContext": true,
797799
"isViewPortScreenshot": true,
798800
"options": {
@@ -953,6 +955,7 @@ exports[`checkAppScreen > should spread hideElements and removeElements into ign
953955
exports[`checkAppScreen > should spread hideElements and removeElements into ignore array 2`] = `
954956
[
955957
{
958+
"actualBase64Image": undefined,
956959
"isNativeContext": true,
957960
"isViewPortScreenshot": true,
958961
"options": {

packages/image-comparison-core/src/commands/__snapshots__/checkFullPageScreen.test.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ exports[`checkFullPageScreen > should execute checkFullPageScreen with basic opt
159159
exports[`checkFullPageScreen > should handle Android device correctly 1`] = `
160160
[
161161
{
162-
162+
"actualBase64Image": undefined,
163163
"isNativeContext": false,
164164
"isViewPortScreenshot": false,
165165
"options": {
@@ -698,6 +698,7 @@ exports[`checkFullPageScreen > should handle hideElements and removeElements cor
698698
exports[`checkFullPageScreen > should handle hybrid app options correctly 1`] = `
699699
[
700700
{
701+
"actualBase64Image": undefined,
701702
"isNativeContext": false,
702703
"isViewPortScreenshot": false,
703704
"options": {
@@ -929,6 +930,7 @@ exports[`checkFullPageScreen > should handle undefined method options with fallb
929930
exports[`checkFullPageScreen > should merge compare options correctly 1`] = `
930931
[
931932
{
933+
"actualBase64Image": undefined,
932934
"isNativeContext": false,
933935
"isViewPortScreenshot": false,
934936
"options": {

packages/image-comparison-core/src/commands/__snapshots__/checkWebElement.test.ts.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ exports[`checkWebElement > should execute checkWebElement with basic options 2`]
161161
exports[`checkWebElement > should execute checkWebElement with basic options 3`] = `
162162
[
163163
{
164+
"actualBase64Image": undefined,
164165
"isNativeContext": false,
165166
"isViewPortScreenshot": true,
166167
"options": {
@@ -244,6 +245,7 @@ exports[`checkWebElement > should execute checkWebElement with basic options 3`]
244245
exports[`checkWebElement > should handle Android device correctly 1`] = `
245246
[
246247
{
248+
"actualBase64Image": undefined,
247249
"isNativeContext": false,
248250
"isViewPortScreenshot": true,
249251
"options": {
@@ -327,6 +329,7 @@ exports[`checkWebElement > should handle Android device correctly 1`] = `
327329
exports[`checkWebElement > should handle compare options correctly 1`] = `
328330
[
329331
{
332+
"actualBase64Image": undefined,
330333
"isNativeContext": false,
331334
"isViewPortScreenshot": true,
332335
"options": {
@@ -581,6 +584,7 @@ exports[`checkWebElement > should handle custom element options 1`] = `
581584
exports[`checkWebElement > should handle device rectangles correctly 1`] = `
582585
[
583586
{
587+
"actualBase64Image": undefined,
584588
"isNativeContext": false,
585589
"isViewPortScreenshot": true,
586590
"options": {
@@ -664,6 +668,7 @@ exports[`checkWebElement > should handle device rectangles correctly 1`] = `
664668
exports[`checkWebElement > should handle hybrid app options correctly 1`] = `
665669
[
666670
{
671+
"actualBase64Image": undefined,
667672
"isNativeContext": false,
668673
"isViewPortScreenshot": true,
669674
"options": {

packages/image-comparison-core/src/commands/__snapshots__/checkWebScreen.test.ts.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ exports[`checkWebScreen > should execute checkWebScreen with basic options 2`] =
158158
exports[`checkWebScreen > should execute checkWebScreen with basic options 3`] = `
159159
[
160160
{
161+
"actualBase64Image": undefined,
161162
"isNativeContext": false,
162163
"isViewPortScreenshot": true,
163164
"options": {
@@ -240,6 +241,7 @@ exports[`checkWebScreen > should execute checkWebScreen with basic options 3`] =
240241
exports[`checkWebScreen > should handle Android device correctly 1`] = `
241242
[
242243
{
244+
"actualBase64Image": undefined,
243245
"isNativeContext": false,
244246
"isViewPortScreenshot": true,
245247
"options": {
@@ -483,6 +485,7 @@ exports[`checkWebScreen > should handle all method options correctly 1`] = `
483485
exports[`checkWebScreen > should handle all method options correctly 2`] = `
484486
[
485487
{
488+
"actualBase64Image": undefined,
486489
"isNativeContext": false,
487490
"isViewPortScreenshot": true,
488491
"options": {
@@ -726,6 +729,7 @@ exports[`checkWebScreen > should handle hideElements and removeElements correctl
726729
exports[`checkWebScreen > should handle hideElements and removeElements correctly 2`] = `
727730
[
728731
{
732+
"actualBase64Image": undefined,
729733
"isNativeContext": false,
730734
"isViewPortScreenshot": true,
731735
"options": {
@@ -953,6 +957,7 @@ exports[`checkWebScreen > should handle native context correctly 1`] = `
953957
exports[`checkWebScreen > should handle native context correctly 2`] = `
954958
[
955959
{
960+
"actualBase64Image": undefined,
956961
"isNativeContext": true,
957962
"isViewPortScreenshot": true,
958963
"options": {
@@ -1180,6 +1185,7 @@ exports[`checkWebScreen > should merge compare options correctly 1`] = `
11801185
exports[`checkWebScreen > should merge compare options correctly 2`] = `
11811186
[
11821187
{
1188+
"actualBase64Image": undefined,
11831189
"isNativeContext": false,
11841190
"isViewPortScreenshot": true,
11851191
"options": {
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`afterScreenshot > should be able to return the ScreenshotOutput with default options 1`] = `
4+
{
5+
"devicePixelRatio": 2,
6+
"fileName": "mocked-file-name.png",
7+
"isLandscape": false,
8+
"path": "/mocked/path",
9+
}
10+
`;
11+
12+
exports[`afterScreenshot > should handle hide/remove elements with error handling 1`] = `
13+
[
14+
"%s",
15+
"
16+
#####################################################################################
17+
WARNING:
18+
(One of) the elements that needed to be hidden or removed could not be found on the
19+
page and caused this error
20+
Error: Error: Element not found
21+
We made sure the test didn't break.
22+
#####################################################################################
23+
",
24+
]
25+
`;
26+
27+
exports[`afterScreenshot > should handle hide/remove elements with error handling 2`] = `
28+
{
29+
"devicePixelRatio": 2,
30+
"fileName": "mocked-file-name.png",
31+
"isLandscape": false,
32+
"path": "/mocked/path",
33+
}
34+
`;
35+
36+
exports[`afterScreenshot > should handle hideScrollBars when hideScrollBars is true 1`] = `
37+
{
38+
"devicePixelRatio": 2,
39+
"fileName": "mocked-file-name.png",
40+
"isLandscape": false,
41+
"path": "/mocked/path",
42+
}
43+
`;
44+
45+
exports[`afterScreenshot > should handle layout testing with enableLayoutTesting 1`] = `
46+
{
47+
"devicePixelRatio": 2,
48+
"fileName": "mocked-file-name.png",
49+
"isLandscape": false,
50+
"path": "/mocked/path",
51+
}
52+
`;
53+
54+
exports[`afterScreenshot > should handle mobile platform and remove custom CSS 1`] = `
55+
{
56+
"devicePixelRatio": 2,
57+
"fileName": "mocked-file-name.png",
58+
"isLandscape": false,
59+
"path": "/mocked/path",
60+
}
61+
`;
62+
63+
exports[`afterScreenshot > should handle native context and skip browser operations 1`] = `
64+
{
65+
"devicePixelRatio": 1.5,
66+
"fileName": "mocked-file-name.png",
67+
"isLandscape": true,
68+
"path": "/mocked/path",
69+
}
70+
`;
71+
72+
exports[`afterScreenshot > should handle only hideElements with length > 0 1`] = `
73+
{
74+
"devicePixelRatio": 2,
75+
"fileName": "mocked-file-name.png",
76+
"isLandscape": false,
77+
"path": "/mocked/path",
78+
}
79+
`;
80+
81+
exports[`afterScreenshot > should handle only removeElements with length > 0 1`] = `
82+
{
83+
"devicePixelRatio": 2,
84+
"fileName": "mocked-file-name.png",
85+
"isLandscape": false,
86+
"path": "/mocked/path",
87+
}
88+
`;
89+
90+
exports[`afterScreenshot > should skip hide/remove elements when both are empty arrays 1`] = `
91+
{
92+
"devicePixelRatio": 2,
93+
"fileName": "mocked-file-name.png",
94+
"isLandscape": false,
95+
"path": "/mocked/path",
96+
}
97+
`;
98+
99+
exports[`afterScreenshot > should skip hide/remove elements when both are falsy 1`] = `
100+
{
101+
"devicePixelRatio": 2,
102+
"fileName": "mocked-file-name.png",
103+
"isLandscape": false,
104+
"path": "/mocked/path",
105+
}
106+
`;

packages/image-comparison-core/src/helpers/afterScreenshot.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ describe('afterScreenshot', () => {
7979
isLandscape: false,
8080
isNativeContext: false,
8181
platformName: '',
82+
alwaysSaveActualImage: true,
8283
...overrides,
8384
})
8485

0 commit comments

Comments
 (0)