Skip to content

Commit 3f33e0c

Browse files
committed
jest-image-snapshot
1 parent 2d568ee commit 3f33e0c

14 files changed

Lines changed: 48 additions & 1 deletion

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ LICENSE
99
dist/
1010
build/
1111
*.gif
12+
*.png

examples/Boxes.test.e2e.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ test('resize', async () => {
3030
'box grey flex-fill',
3131
'box yellow'
3232
]);
33+
34+
expect(await page.screenshot()).toMatchImageSnapshot({
35+
failureThreshold: 2,
36+
failureThresholdType: 'percent'
37+
});
3338
}
3439

3540
{
@@ -52,6 +57,11 @@ test('resize', async () => {
5257
'box grey flex-fill',
5358
'box yellow'
5459
]);
60+
61+
expect(await page.screenshot()).toMatchImageSnapshot({
62+
failureThreshold: 2,
63+
failureThresholdType: 'percent'
64+
});
5565
}
5666

5767
{
@@ -74,6 +84,11 @@ test('resize', async () => {
7484
'box grey flex-fill',
7585
'box yellow'
7686
]);
87+
88+
expect(await page.screenshot()).toMatchImageSnapshot({
89+
failureThreshold: 2,
90+
failureThresholdType: 'percent'
91+
});
7792
}
7893

7994
{
@@ -96,6 +111,11 @@ test('resize', async () => {
96111
'box grey flex-fill next-is-wrapped',
97112
'box yellow'
98113
]);
114+
115+
expect(await page.screenshot()).toMatchImageSnapshot({
116+
failureThreshold: 2,
117+
failureThresholdType: 'percent'
118+
});
99119
}
100120

101121
{
@@ -118,5 +138,10 @@ test('resize', async () => {
118138
'box grey flex-fill next-is-wrapped',
119139
'box yellow'
120140
]);
141+
142+
expect(await page.screenshot()).toMatchImageSnapshot({
143+
failureThreshold: 2,
144+
failureThresholdType: 'percent'
145+
});
121146
}
122147
});

examples/Minimal.test.e2e.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ test('resize 1024px => 296px => 183px', async () => {
3333
expect(child1ClassName).toEqual('');
3434
expect(child2BoundingBox).toEqual({ x: 908.046875, y: 13, width: 102.953125, height: 72 });
3535
expect(child2ClassName).toEqual('');
36+
37+
expect(await page.screenshot()).toMatchImageSnapshot({
38+
failureThreshold: 0.1,
39+
failureThresholdType: 'percent'
40+
});
3641
}
3742

3843
{
@@ -55,6 +60,11 @@ test('resize 1024px => 296px => 183px', async () => {
5560
expect(child1ClassName).toEqual(nextIsWrappedClassName);
5661
expect(child2BoundingBox).toEqual({ x: 13, y: 95, width: 270, height: 72 });
5762
expect(child2ClassName).toEqual('');
63+
64+
expect(await page.screenshot()).toMatchImageSnapshot({
65+
failureThreshold: 0.1,
66+
failureThresholdType: 'percent'
67+
});
5868
}
5969

6070
{
@@ -77,5 +87,10 @@ test('resize 1024px => 296px => 183px', async () => {
7787
expect(child1ClassName).toEqual(nextIsWrappedClassName);
7888
expect(child2BoundingBox).toEqual({ x: 13, y: 177, width: 157, height: 72 });
7989
expect(child2ClassName).toEqual('');
90+
91+
expect(await page.screenshot()).toMatchImageSnapshot({
92+
failureThreshold: 0.1,
93+
failureThresholdType: 'percent'
94+
});
8095
}
8196
});
20 KB
Loading
21.9 KB
Loading
22 KB
Loading
21.5 KB
Loading
21 KB
Loading
8.17 KB
Loading
6.21 KB
Loading

0 commit comments

Comments
 (0)