Adding a snapshot test using a ListView fails with the following error:
console.error node_modules/react-native/Libraries/Core/ExceptionsManager.js:71
Warning: Each child in an array or iterator should have a unique "key" prop.
Check the render method of `ScrollViewMock`.
It was passed a child from ListViewMock. See https://fb.me/react-warning-keys for more information.
Code snippet:
exportclassAppextendsComponent{state={dataSource: newListView.DataSource({rowHasChanged: (r1,r2)=>r1!==r2}),};componentWillReceiveProps({ results }){this.setState({dataSource: this.state.dataSource.cloneWithRows(results),});}renderHeader=()=>(<Header/>);renderRow=resultInfo=>(<ResultCellresultInfo={resultInfo}/>)renderFooter=()=>{const{ results }=this.props;if(results.length>=results.totalItems){returnnull;}return<ActivityIndicator/>;}render(){return(<ListViewdataSource={this.state.dataSource}enableEmptySectionsrenderHeader={this.renderHeader}onScroll={Keyboard.dismiss}renderRow={this.renderRow}renderFooter={this.renderFooter}/>);}}Test:
test('renders correctly',()=>{consttree=renderer.create(<Appresults={[]}/>).toJSON();expect(tree).toMatchSnapshot();});react native: 0.42.0
jest: 19.0.2
yarn: 0.21.3
os: macOS
Adding a snapshot test using a ListView fails with the following error:
Code snippet:
Test:
react native: 0.42.0
jest: 19.0.2
yarn: 0.21.3
os: macOS