mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
Set up Jest to be able to test RN UI components (#96)
This commit is contained in:
committed by
Satyajit Sahoo
parent
123bce5402
commit
d0582d205d
3
.gitignore
vendored
3
.gitignore
vendored
@@ -17,3 +17,6 @@ yarn-error.log
|
||||
|
||||
# Exponent
|
||||
.exponent
|
||||
|
||||
# Jest
|
||||
coverage
|
||||
21
jest-setup.js
Normal file
21
jest-setup.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/* @flow */
|
||||
|
||||
// See https://github.com/facebook/jest/issues/2208
|
||||
jest.mock('Linking', () => {
|
||||
return {
|
||||
addEventListener: jest.fn(),
|
||||
removeEventListener: jest.fn(),
|
||||
openURL: jest.fn(),
|
||||
canOpenURL: jest.fn(),
|
||||
getInitialURL: jest.fn().mockImplementation((value: string) => Promise.resolve(value)),
|
||||
}
|
||||
});
|
||||
|
||||
// See https://github.com/facebook/react-native/issues/11659
|
||||
jest.mock('ScrollView', () => {
|
||||
const RealComponent = require.requireActual('ScrollView');
|
||||
class ScrollView extends RealComponent {
|
||||
scrollTo = () => {}
|
||||
}
|
||||
return ScrollView
|
||||
});
|
||||
16
package.json
16
package.json
@@ -26,7 +26,7 @@
|
||||
"start": "node ./node_modules/react-native/local-cli/cli.js start --config ./rn-cli.config.js",
|
||||
"run-playground-ios": "cd examples/NavigationPlayground && react-native run-ios",
|
||||
"run-playground-android": "cd examples/NavigationPlayground && react-native run-android",
|
||||
"test": "BABEL_ENV=development jest",
|
||||
"test": "jest",
|
||||
"flow": "flow",
|
||||
"prepublish": "npm run clean && npm run build"
|
||||
},
|
||||
@@ -55,7 +55,8 @@
|
||||
"jest": "^18.1.0",
|
||||
"react": "~15.4.0",
|
||||
"react-native": "^0.40.0",
|
||||
"react-native-vector-icons": "^3.0.0"
|
||||
"react-native-vector-icons": "^3.0.0",
|
||||
"react-test-renderer": "^15.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
@@ -69,9 +70,14 @@
|
||||
"react-native-tab-view": "^0.0.54"
|
||||
},
|
||||
"jest": {
|
||||
"testPathDirs": [
|
||||
"src/"
|
||||
"notify": true,
|
||||
"preset": "react-native",
|
||||
"testRegex": "./src/.*\\-test\\.js$",
|
||||
"setupFiles": [
|
||||
"<rootDir>/jest-setup.js"
|
||||
],
|
||||
"notify": true
|
||||
"modulePathIgnorePatterns": [
|
||||
"examples"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3904,6 +3904,13 @@ react-proxy@^1.1.7:
|
||||
lodash "^4.6.1"
|
||||
react-deep-force-update "^1.0.0"
|
||||
|
||||
react-test-renderer@^15.4.2:
|
||||
version "15.4.2"
|
||||
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-15.4.2.tgz#27e1dff5d26d0e830f99614c487622bc831416f3"
|
||||
dependencies:
|
||||
fbjs "^0.8.4"
|
||||
object-assign "^4.1.0"
|
||||
|
||||
react-timer-mixin@^0.13.2:
|
||||
version "0.13.3"
|
||||
resolved "https://modules.verse.link/react-timer-mixin/-/react-timer-mixin-0.13.3.tgz#0da8b9f807ec07dc3e854d082c737c65605b3d22"
|
||||
|
||||
Reference in New Issue
Block a user