forked from Prior99/jest-screenshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-framework-setup.ts
87 lines (82 loc) · 4 KB
/
jest-framework-setup.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(global as any).requestAnimationFrame = (callback: Function) => setTimeout(callback, 0);
import * as Enzyme from "enzyme";
import * as Adapter from "enzyme-adapter-react-16";
import { TSDI } from "tsdi";
Enzyme.configure({ adapter: new Adapter() });
beforeEach(() => {
(global as any).testResults = {
files: [
{
testFilePath: "src/__tests__/test-first.ts",
failedTests: [
{
titles: ["The thing", "with this other thing", "does things"],
failedSnapshots: [
{
testName: "The first snapshots",
message: "Received message.",
changedRelative: 0.5,
totalPixels: 10,
changedPixels: 5,
testFileName: "src/__tests__/test-first.ts",
snapshotNumber: 1,
receivedPath: "jest-screenshot-report/reports/some-identifier.snap.png/received.png",
diffPath: "jest-screenshot-report/reports/some-identifier.snap.png/diff.png",
snapshotPath: "jest-screenshot-report/reports/some-identifier.snap.png/snapshot.png",
width: 5,
height: 2,
},
{
testName: "The first snapshots",
message: "Received message.",
changedRelative: 0.2,
totalPixels: 100,
changedPixels: 20,
testFileName: "src/__tests__/test-first.ts",
snapshotNumber: 2,
receivedPath:
"jest-screenshot-report/reports/some-other-identifier.snap.png/received.png",
diffPath: "jest-screenshot-report/reports/some-other-identifier.snap.png/diff.png",
snapshotPath:
"jest-screenshot-report/reports/some-other-identifier.snap.png/snapshot.png",
width: 10,
height: 10,
},
],
},
],
},
{
testFilePath: "src/__tests__/test-second.ts",
failedTests: [
{
titles: ["The second thing", "with this specific behaviour", "does other things"],
failedSnapshots: [
{
testName: "The second snapshots",
message: "Received other message.",
changedRelative: 0.75,
totalPixels: 100,
changedPixels: 75,
testFileName: "src/__tests__/test-second.ts",
snapshotNumber: 1,
receivedPath:
"jest-screenshot-report/reports/some-third-identifier.snap.png/received.png",
diffPath: "jest-screenshot-report/reports/some-third-identifier.snap.png/diff.png",
snapshotPath:
"jest-screenshot-report/reports/some-third-identifier.snap.png/snapshot.png",
width: 5,
height: 20,
},
],
},
],
},
],
},
(global as any).tsdi = new TSDI();
(global as any).tsdi.enableComponentScanner();
});
afterEach(() => {
(global as any).tsdi.close();
});