-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjest.setup.js
More file actions
30 lines (26 loc) · 781 Bytes
/
jest.setup.js
File metadata and controls
30 lines (26 loc) · 781 Bytes
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
// Backup of the native console object for later re-use
global._console = global.console;
// Force mute console by returning a mock object that mocks the props we use
global.muteConsole = () => {
return {
debug: jest.fn(),
error: jest.fn(),
info: jest.fn(),
log: jest.fn(),
warn: jest.fn(),
};
};
// Force mute console by returning a mock object that mocks the props we use, except for "log"
global.muteConsoleButLog = () => {
return {
debug: jest.fn(),
error: jest.fn(),
info: jest.fn(),
log: _console.log,
warn: jest.fn(),
};
};
// Restore previously made "console" object
global.unmuteConsole = () => _console;
// Mock __non_webpack_require__ to use the standard node.js "require"
global['__non_webpack_require__'] = require;