-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrapper.prop(key) function returning undefined on with React Native components #331
Comments
wrapper.props throws a similar error: |
Probably related RealOrangeOne/react-native-mock#33 |
@jerrysu's link is on point, that's exactly the reason you're seeing this behavior. Specifically:
So you're It's probably also worth mentioning that a test like: const wrapper = shallow(<Text value={50} />);
expect(wrapper.prop('value')).to.equal(50); is essentially meaningless. You just passed in I'm closing this since it's expected behavior, but feel free to ask any additional questions! |
I also had this problem, I was able to solve it when I used it('should render a url property', () => {
const url = 'https://github.com'
const wrapper = mount(<GithubButton url={url} />)
expect(wrapper.props().url).toEqual(url)
}) Docs: https://enzymejs.github.io/enzyme/docs/api/ReactWrapper/props.html |
Running shallow tests on the below code I get errors due to .prop() returning undefined rather than the value corresponding to the prop key. Console output and a log of one of the objects follow below.
Inserting
console.log(wrapper);
into the test, the object shows that the prop value is there:I've tested this with View and TextInput and had the same issue.
The text was updated successfully, but these errors were encountered: