@@ -16,19 +16,37 @@ const BINARY_PATH = path.resolve(
16
16
17
17
console . log ( `Testing binary ${ BINARY_PATH } ` ) ;
18
18
19
+ const options = {
20
+ __binaryPath : BINARY_PATH ,
21
+ }
22
+
19
23
test ( "Outputs correct parsed result when images different" , async ( t ) => {
24
+ const { reason, diffCount, diffPercentage } = await compare (
25
+ path . join ( IMAGES_PATH , "donkey.png" ) ,
26
+ path . join ( IMAGES_PATH , "donkey-2.png" ) ,
27
+ path . join ( IMAGES_PATH , "diff.png" ) ,
28
+ options
29
+ ) ;
30
+
31
+ t . is ( reason , "pixel-diff" ) ;
32
+ t . is ( diffCount , 101841 ) ;
33
+ t . is ( diffPercentage , 2.65077570347 ) ;
34
+ } )
35
+
36
+ test ( "Correctly works with reduceRamUsage" , async ( t ) => {
20
37
const { reason, diffCount, diffPercentage } = await compare (
21
38
path . join ( IMAGES_PATH , "donkey.png" ) ,
22
39
path . join ( IMAGES_PATH , "donkey-2.png" ) ,
23
40
path . join ( IMAGES_PATH , "diff.png" ) ,
24
41
{
25
- __binaryPath : BINARY_PATH ,
42
+ ...options ,
43
+ reduceRamUsage : true ,
26
44
}
27
45
) ;
28
46
29
47
t . is ( reason , "pixel-diff" ) ;
30
- t . is ( diffCount , 109861 ) ;
31
- t . is ( diffPercentage , 2.85952484323 ) ;
48
+ t . is ( diffCount , 101841 ) ;
49
+ t . is ( diffPercentage , 2.65077570347 ) ;
32
50
} ) ;
33
51
34
52
test ( "Correctly parses threshold" , async ( t ) => {
@@ -37,14 +55,14 @@ test("Correctly parses threshold", async (t) => {
37
55
path . join ( IMAGES_PATH , "donkey-2.png" ) ,
38
56
path . join ( IMAGES_PATH , "diff.png" ) ,
39
57
{
40
- threshold : 0.6 ,
41
- __binaryPath : BINARY_PATH ,
58
+ ... options ,
59
+ threshold : 0.5 ,
42
60
}
43
61
) ;
44
62
45
63
t . is ( reason , "pixel-diff" ) ;
46
- t . is ( diffCount , 50332 ) ;
47
- t . is ( diffPercentage , 1.31007003768 ) ;
64
+ t . is ( diffCount , 65357 ) ;
65
+ t . is ( diffPercentage , 1.70114931758 ) ;
48
66
} ) ;
49
67
50
68
test ( "Correctly parses antialiasing" , async ( t ) => {
@@ -53,14 +71,14 @@ test("Correctly parses antialiasing", async (t) => {
53
71
path . join ( IMAGES_PATH , "donkey-2.png" ) ,
54
72
path . join ( IMAGES_PATH , "diff.png" ) ,
55
73
{
74
+ ...options ,
56
75
antialiasing : true ,
57
- __binaryPath : BINARY_PATH ,
58
76
}
59
77
) ;
60
78
61
79
t . is ( reason , "pixel-diff" ) ;
62
- t . is ( diffCount , 108208 ) ;
63
- t . is ( diffPercentage , 2.8164996153 ) ;
80
+ t . is ( diffCount , 101499 ) ;
81
+ t . is ( diffPercentage , 2.64187393218 ) ;
64
82
} ) ;
65
83
66
84
test ( "Correctly parses ignore regions" , async ( t ) => {
@@ -69,6 +87,7 @@ test("Correctly parses ignore regions", async (t) => {
69
87
path . join ( IMAGES_PATH , "donkey-2.png" ) ,
70
88
path . join ( IMAGES_PATH , "diff.png" ) ,
71
89
{
90
+ ...options ,
72
91
ignoreRegions : [
73
92
{
74
93
x1 : 749 ,
@@ -83,7 +102,6 @@ test("Correctly parses ignore regions", async (t) => {
83
102
y2 : 1334 ,
84
103
} ,
85
104
] ,
86
- __binaryPath : BINARY_PATH ,
87
105
}
88
106
) ;
89
107
@@ -95,9 +113,7 @@ test("Outputs correct parsed result when images different for cypress image", as
95
113
path . join ( IMAGES_PATH , "www.cypress.io.png" ) ,
96
114
path . join ( IMAGES_PATH , "www.cypress.io-1.png" ) ,
97
115
path . join ( IMAGES_PATH , "diff.png" ) ,
98
- {
99
- __binaryPath : BINARY_PATH ,
100
- }
116
+ options
101
117
) ;
102
118
103
119
t . is ( reason , "pixel-diff" ) ;
@@ -110,9 +126,7 @@ test("Correctly handles same images", async (t) => {
110
126
path . join ( IMAGES_PATH , "donkey.png" ) ,
111
127
path . join ( IMAGES_PATH , "donkey.png" ) ,
112
128
path . join ( IMAGES_PATH , "diff.png" ) ,
113
- {
114
- __binaryPath : BINARY_PATH ,
115
- }
129
+ options
116
130
) ;
117
131
118
132
t . is ( match , true ) ;
@@ -125,12 +139,12 @@ test("Correctly outputs diff lines", async (t) => {
125
139
path . join ( IMAGES_PATH , "diff.png" ) ,
126
140
{
127
141
captureDiffLines : true ,
128
- __binaryPath : BINARY_PATH ,
142
+ ... options
129
143
}
130
144
) ;
131
145
132
146
t . is ( match , false ) ;
133
- t . is ( diffLines . length , 411 ) ;
147
+ t . is ( diffLines . length , 402 ) ;
134
148
} ) ;
135
149
136
150
test ( "Returns meaningful error if file does not exist and noFailOnFsErrors" , async ( t ) => {
@@ -139,8 +153,8 @@ test("Returns meaningful error if file does not exist and noFailOnFsErrors", asy
139
153
path . join ( IMAGES_PATH , "not-existing.png" ) ,
140
154
path . join ( IMAGES_PATH , "diff.png" ) ,
141
155
{
156
+ ...options ,
142
157
noFailOnFsErrors : true ,
143
- __binaryPath : BINARY_PATH ,
144
158
}
145
159
) ;
146
160
0 commit comments