-
Notifications
You must be signed in to change notification settings - Fork 1
/
setupTests.js
32 lines (24 loc) · 875 Bytes
/
setupTests.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
// JsDOM & React-Native-mock-render
// eslint-disable-next-line
const { jsdom } = require('jsdom')
global.document = jsdom('')
global.window = document.defaultView
global.navigator = { userAgent: 'node.js' }
function copyProps(src, target) {
const props = Object.getOwnPropertyNames(src)
.filter(prop => typeof target[prop] === 'undefined')
.reduce((result, prop) => ({
...result,
[prop]: Object.getOwnPropertyDescriptor(src, prop),
}), {})
Object.defineProperties(target, props)
}
copyProps(document.defaultView, global)
// eslint-disable-next-line
jest.mock('react-native', () => require('react-native-mock-render'), {virtual: true})
// Enzyme adapter
// eslint-disable-next-line
const Adapter = require('enzyme-adapter-react-16')
// eslint-disable-next-line
const { configure } = require('enzyme')
configure({ adapter: new Adapter() })