Last active
September 19, 2017 16:17
-
-
Save gjreasoner/cb3a16fc5d793aac56a2f0f26ae0f8ff to your computer and use it in GitHub Desktop.
React Native Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const ReactShallowRenderer = require('react-test-renderer/shallow'); | |
const renderer = new ReactShallowRenderer(); | |
import {LoginScreen} from "../LoginScreen"; | |
import {AsyncStorage} from 'react-native'; | |
import { mock, release } from 'mock-async-storage' | |
import axios from 'axios'; | |
mock() | |
describe('rendering',()=>{ | |
it('loads without crashing',()=>{ | |
AsyncStorage.setItem('user',{hello:'world'}).then(()=>{ | |
AsyncStorage.getItem('user').then(user=>{ | |
console.log('made it here',user); | |
}) | |
}) | |
renderer.render( | |
<LoginScreen/> | |
) | |
const Login = renderer.getMountedInstance(); | |
// Login.attemptLogin(); | |
const result = renderer.getRenderOutput(); | |
// expect(result).toEqual('Florida Grown') | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Example", | |
"version": "0.0.1", | |
"private": true, | |
"scripts": { | |
"start": "node build.js; node node_modules/react-native/local-cli/cli.js start", | |
"test": "jest" | |
}, | |
"dependencies": { | |
"axios": "^0.16.2", | |
"mock-async-storage": "^1.0.3", | |
"moment": "^2.18.1", | |
"prop-types": "^15.5.10", | |
"react": "^16.0.0-rc.2", | |
"react-dom": "^16.0.0-rc.2", | |
"react-native": "0.47.1", | |
"react-native-ble-plx": "^0.4.0", | |
"react-native-checkbox": "^1.1.0", | |
"react-native-orientation": "git+https://github.com/yamill/react-native-orientation.git", | |
"react-native-signature-capture": "^0.4.7", | |
"react-native-svg": "^5.1.8", | |
"react-native-uuid-generator": "^2.0.0", | |
"react-navigation": "^1.0.0-beta.9", | |
"react-navigation-is-focused-hoc": "^1.0.0", | |
"react-redux": "^5.0.5" | |
}, | |
"devDependencies": { | |
"babel-jest": "20.0.3", | |
"babel-preset-react-native": "1.9.2", | |
"enzyme": "^2.9.1", | |
"jest": "20.0.3", | |
"react-addons-test-utils": "^15.0.0-rc.2", | |
"react-test-renderer": "^16.0.0-alpha.12" | |
}, | |
"jest": { | |
"preset": "react-native" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment