ネイティブと酵素と嫌がらせに反応するのは初めてです。私は子ノードをテストするために、簡単なテスト作業をしようとしています。 (おそらくこれはそうしようとしている間違った方法です)。React NativeとEnzymeアサーションエラー:ネストされたプロパティと一致しないオブジェクト
私のコンポーネントは次のとおりです。
import React, { Component } from 'react';
import { View, Text, Button, TextInput } from 'react-native';
class MyComponent extends Component {
constructor(props) {
super(props);
}
render() {
return (
<View >
<Button title="My Component"/>
</View>
)
}
}
export default MyComponent;
と私のテストは
import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import MyComponent from '../components/MyComponent.js';
configure({ adapter: new Adapter() }) //setting up enzyme
const styles = require('../styles.js');
describe('rendering',() => {
it('checking View and Button exists',() => {
let wrapper
wrapper = shallow(<MyComponent/>);
expect(wrapper.find('View').children().find('Button')).toHaveProperty('title','My Component')
});
})
});
である私は、オブジェクトのリターンが期待に一致していないというエラーを取得しています:
Expected the object:
< listing of full object...>
To have a nested property:
"title"
With a value of:
"My Component"
オブジェクト返されたMyComponentは、ルートビューの子として、および小道具として表示されますが、失敗しています。私はこれを違うやり方で行うべきですか?私は、View Componentの下にいくつかの子コンポーネントと小道具を最終的に確認するテスト構造を作りたいと思っています。 は、(サイドノートとして、私はモカを使用することを好むだろうが、私は私が解決することができていないいるthis errorに直面して来ています。
をそれまでの間、私がテストしたスナップショットを使用しています:私が使用するため
ソリューションがあった)正しく信用を与えていないのですか? –