forked from OneKeyHQ/app-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest-setup.js
42 lines (31 loc) · 942 Bytes
/
jest-setup.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
require('react-native-reanimated/lib/reanimated2/jestUtils').setUpTests();
class LocalStorageMock {
constructor() {
this.store = {};
}
clear() {
this.store = {};
}
getItem(key) {
return this.store[key] || null;
}
setItem(key, value) {
this.store[key] = String(value);
}
removeItem(key) {
delete this.store[key];
}
}
global.localStorage = new LocalStorageMock();
// ** shim TextEncoder
// const { TextEncoder, TextDecoder } = require('util');
// global.TextEncoder = TextEncoder;
// global.TextDecoder = TextDecoder;
// ** shim App variables
// require('./packages/app/shim');
// ** Array, Buffer, Error
// https://github.com/facebook/jest/issues/2549
// ** asm.js support
// Linking failure in asm.js: Unexpected stdlib member
// ** await import() support
// Error: You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/ecmascript-modules