-
Notifications
You must be signed in to change notification settings - Fork 4
/
testHelper.js
51 lines (44 loc) · 1.31 KB
/
testHelper.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
import fs from 'fs'
import path from 'path'
import register from 'babel-core/register'
import chai from 'chai'
import chaiEnzyme from 'chai-enzyme'
import mockery from 'mockery'
// Ignore all node_modules except these
const modulesToCompile = [
'react-native',
'apsl-react-native-button',
'react-native-router-flux',
// 'react-native-tabs',
'react-native-vector-icons',
'react-native-mock',
// 'react-native-parallax-scroll-view',
'react-native-simple-store'
].map((moduleName) => new RegExp(`/node_modules/${moduleName}`))
const rcPath = path.join(__dirname, '', '.babelrc')
const source = fs.readFileSync(rcPath).toString()
const config = JSON.parse(source)
config.ignore = function(filename) {
if (!(/\/node_modules\//).test(filename)) {
return false
} else {
const matches = modulesToCompile.filter((regex) => regex.test(filename))
const shouldIgnore = matches.length === 0
return shouldIgnore
}
}
register(config)
// Setup globals / chai
global.__DEV__ = true
global.expect = chai.expect
chai.use(chaiEnzyme())
// Setup mocks
require('react-native-mock/mock')
mockery.enable()
mockery.warnOnUnregistered(false)
mockery.registerMock('react-native-router-flux', 1)
require('babel-polyfill')
const React = require('react-native')
React.NavigationExperimental = {
AnimatedView: React.View
}