Sto cercando di capire come testare i componenti React Native (non React JS). Anche guardando il codice di avviamento di React Native, è difficile vedere come testarlo.Come testare i componenti React Native
var AwesomeProject = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
Sono stato in grado di utilizzare al Babel transpile la sintassi JSX così come l'uso Derisione per deridere la Reagire metodi biblioteca createClass
e StyleSheet.create
, ma alla fine della giornata, io non riesco a creare qualsiasi test significativo
Penso che vogliamo qualcosa di simile alla tecnica di test Reacts Shallow Rendering che viene utilizzata per il web React. Ho postato questa domanda qui: http://stackoverflow.com/questions/32804218/in-react-native-how-can-i-test-my-components-with-shallow-rendering – ooolala
Vedere questa risposta: http: //stackoverflow.com/questions/29730415/how-to-use-jest-with-react-native#comment50964358_29730415 –