-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
init.spec.js
62 lines (53 loc) · 2.6 KB
/
init.spec.js
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
import { copy } from 'fs-extra';
import { normalize, join } from 'path'
describe('webdriverio image comparison local development initialization', () => {
const localBaseline = 'localBaseline';
const checkBaseline = 'checkBaseline';
beforeEach(async () => {
await browser.url('');
await browser.pause(500);
});
// Chrome remembers the last postion when the url is loaded again, this will reset it.
afterEach(() => browser.execute('window.scrollTo(0, 0);', []));
it('should save the compare screenshot screenshots', () => {
const examplePage = 'examplePage';
browser.saveScreen(examplePage);
const { fileName, path } = browser.saveScreen(examplePage);
copy(normalize(`${ path }/${ fileName }`), join(process.cwd(), `./${ localBaseline }/${ path.split('/').pop() }/${ fileName }`));
copy(
normalize(`${ path }/${ fileName }`),
join(process.cwd(), `./${ localBaseline }/${ path.split('/').pop() }/${ fileName.replace(examplePage, 'examplePageFail') }`),
);
copy(
normalize(`${ path }/${ fileName }`),
join(
process.cwd(),
`./${ localBaseline }/${ checkBaseline }/${ path.split('/').pop() }/${ fileName.replace(examplePage, 'screenCheckFolders') }`
),
);
});
it('should save the compare element screenshot', () => {
const firstButtonElement = 'firstButtonElement';
const { fileName, path } = browser.saveElement($('.uk-button:nth-child(1)'), firstButtonElement);
copy(normalize(`${ path }/${ fileName }`), join(process.cwd(), `./${ localBaseline }/${ path.split('/').pop() }/${ fileName }`));
copy(
normalize(`${ path }/${ fileName }`),
join(
process.cwd(),
`./${ localBaseline }/${ checkBaseline }/${ path.split('/').pop() }/${ fileName.replace(firstButtonElement, 'elementCheckFolders') }`
),
);
});
it('should save the compare fullpage screenshots', () => {
const fullPage = 'fullPage';
const { fileName, path } = browser.saveFullPageScreen(fullPage, { fullPageScrollTimeout: '1500' });
copy(normalize(`${ path }/${ fileName }`), join(process.cwd(), `./${ localBaseline }/${ path.split('/').pop() }/${ fileName }`));
copy(
normalize(`${ path }/${ fileName }`),
join(
process.cwd(),
`./${ localBaseline }/${ checkBaseline }/${ path.split('/').pop() }/${ fileName.replace(fullPage, 'fullPageCheckFolders') }`,
),
);
});
});