This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsetup_jest.js
134 lines (130 loc) · 3.84 KB
/
setup_jest.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import Enzyme, { shallow, render, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import toJson from 'enzyme-to-json';
// React 16 Enzyme adapter
Enzyme.configure({ adapter: new Adapter() });
// Make Enzyme functions available in all test files without importing
global.shallow = shallow;
global.render = render;
global.mount = mount;
global.toJson = toJson;
global.window.require = function() {
return {
ipcRenderer: {
send: function() {
// Fake sending message to ipcMain
},
on: function() {
// Fake receiving message to ipcMain
}
},
webFrame: {
setZoomLevelLimits: function() {},
setVisualZoomLevelLimits: function() {}
},
remote: {
require: function() {
return {
dirToJson: function() {
return new Promise((res, rej) => {});
},
getDefaultLocation: function() {},
selectDirectory: function() {
return new Promise((res, rej) => {});
},
checkUpdate: function(_old, _new) {},
warn: function() {},
isMac: function() {},
isWin: function() {}
};
},
getGlobal: function() {
return {
setConfig: function() {},
getConfig: function() {},
dictConfig: function() {},
configStore: {
onDidChange: function() {}
},
env: {
NODE_ENV: function() {}
}
};
},
dialog: {
showOpenDialog: function() {}
},
BrowserWindow: function() {},
app: {
getVersion: function() {}
},
process: {
argv: {
includes: function() {}
}
}
}
};
};
global.window.electron = {
remote: {
process: {
argv: {
includes: function() {}
}
},
require: function() {
return {
dirToJson: function() {
return new Promise((res, rej) => {});
},
getDefaultLocation: function() {},
selectDirectory: function() {
return new Promise((res, rej) => {});
},
checkUpdate: function(_old, _new) {},
warn: function() {},
isMac: function() {},
isWin: function() {}
};
},
getGlobal: function() {
return {
setConfig: function() {},
getConfig: function() {},
dictConfig: function() {},
configStore: {
onDidChange: function() {}
}
};
},
dialog: {
showOpenDialog: function() {}
},
app: {
getVersion: function() {}
},
BrowserWindow: function() {}
},
ipcRenderer: {
send: function() {
// Fake sending message to ipcMain
},
on: function() {
// Fake receiving message to ipcMain
}
},
clipboard: {
writeText: function() {}
},
webFrame: {
setZoomLevelLimits: function() {},
setVisualZoomLevelLimits: function() {}
}
};
// Skip createElement warnings but fail tests on any other warning
/*console.error = message => {
if (!/(React.createElement: type should not be null)/.test(message)) {
throw new Error(message);
}
};*/