Sha*_*ssy 12 unit-testing react-native
我正在试图弄清楚如何测试React Native(而不是React JS)组件.即使查看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,
},
});
Run Code Online (Sandbox Code Playgroud)
我已经能够使用通天transpile的JSX语法以及使用嘲笑嘲笑阵营库方法createClass和StyleSheet.create,但在一天结束的时候,我似乎无法创造任何有意义的测试.
最后,我使用 Mocha 与 TravisCI 设置了一个存储库,用于 BDD 风格的单元测试。您可以在以下位置查看该存储库:https ://github.com/sghiassy/react-native-sglistview
| 归档时间: |
|
| 查看次数: |
4280 次 |
| 最近记录: |