forked from aws-amplify/amplify-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
36 lines (32 loc) · 766 Bytes
/
jest.setup.js
File metadata and controls
36 lines (32 loc) · 766 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
31
32
33
34
35
36
// Suppress console messages printing during unit tests.
// Comment out log level as necessary (e.g. while debugging tests)
global.console = {
...console,
log: jest.fn(),
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
};
// React Native global
global['__DEV__'] = true;
/* this is available according to
https://developer.mozilla.org/en-US/docs/Web/API/URL
for react-native use:
import { loadUrlPolyfill } from '@aws-amplify/react-native';
*/
Object.defineProperty(URL, 'parse', {
value: (path, origin) => {
try {
return new URL(path, origin);
} catch {
return null;
}
},
});
Object.defineProperty(URL, 'canParse', {
value: (path, origin) => {
const out = URL.parse(path, origin);
return null !== out;
},
});