-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (41 loc) · 1.12 KB
/
index.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
import '@shelex/cypress-allure-plugin';
import 'cypress-plugin-snapshots/commands';
let snapshot;
Cypress.on('log:added', (log) => {
if (log.name === 'toMatchImageSnapshot') {
snapshot = log.message;
}
});
afterEach(() => {
const state = Cypress.state();
if (
state.error &&
state.error.message === 'Snapshot images do not match.'
) {
if (!snapshot) {
return;
}
const base64 = snapshot
.replace('[compare snapshot](#cypress-plugin-snapshot-', '')
.slice(0, -1);
const snapshotInfo = JSON.parse(atob(base64));
cy.allure()
.label('testType', 'screenshotDiff')
.fileAttachment(
'actual',
snapshotInfo.actual.path,
'image/png'
)
.fileAttachment(
'expected',
snapshotInfo.expected.path,
'image/png'
)
.fileAttachment(
'diff',
snapshotInfo.diff.path,
'image/png'
);
}
snapshot = null;
});