forked from lost-pixel/lost-pixel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpageScreenshots.spec.ts
68 lines (58 loc) · 1.6 KB
/
pageScreenshots.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { createShotsFolders } from '../utils';
import { type PageScreenshotParameter, configure } from '../config';
import { generatePageShotItems } from './pageScreenshots';
beforeAll(async () => {
await configure({
customProjectConfig: {
timeouts: {
fetchStories: 2000,
},
},
});
createShotsFolders();
process.env.FETCH_STORIES_TIMEOUT = '2000';
});
describe(generatePageShotItems, () => {
it('should generate shot items for pages without breakpoints', () => {
const baseUrl = 'https://example.com';
const pages: PageScreenshotParameter[] = [
{
name: 'home',
path: '/',
breakpoints: [],
threshold: 0,
waitBeforeScreenshot: 1000,
},
{
name: 'about',
path: '/about',
breakpoints: [],
threshold: 0,
waitBeforeScreenshot: 1000,
},
];
const shotItems = generatePageShotItems(pages, baseUrl);
expect(shotItems).toMatchSnapshot('PagesWithoutBreakpoints');
});
it('should generate shot items for pages with breakpoints', () => {
const baseUrl = 'https://example.com';
const pages: PageScreenshotParameter[] = [
{
name: 'home',
path: '/',
breakpoints: [480, 768],
threshold: 0,
waitBeforeScreenshot: 1000,
},
{
name: 'about',
path: '/about',
breakpoints: [480, 768],
threshold: 0,
waitBeforeScreenshot: 1000,
},
];
const shotItems = generatePageShotItems(pages, baseUrl);
expect(shotItems).toMatchSnapshot('PagesWithBreakpoints');
});
});