Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add snapshots for mocked and unmocked components part 2 #24593

Closed
wants to merge 4 commits into from
Closed

add snapshots for mocked and unmocked components part 2 #24593

wants to merge 4 commits into from

Conversation

bcarroll22
Copy link
Contributor

Summary

Per conversation with @TheSavior, in #24538, this adds snapshot tests for more components. Shallow and deep snapshots are included.

Changelog

[General] [Added] - Snapshots

Test Plan

This PR adds a lot of tests 馃槃

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 25, 2019
describe('<Picker />', () => {
it('should render as <View> when mocked', () => {
const instance = render.create(
<Picker selectedValue="foo" onValueChange={jest.fn()}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be abstracting this out into a constant at the top? It鈥檚 pretty important that they are consistent across all of the tests, right? Probably should do that for all of the tests.


const React = require('React');
// $FlowFixMe
const ProgressBarAndroid = require('../ProgressBarAndroid.android');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer do you know how to fix this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. The iOS flow config doesn't see these modules. I don't think it matters much.

`;

exports[`<Modal /> should shallow render as <Component> when mocked 1`] = `
<Component
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of displayName being broken. We鈥檒l need to fix this. Can you either fix it in this PR or change the name of this test to be consistent with the other component tests so it is clear this isn鈥檛 correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃 hmm modal is a mocked component. Are you sure this line isn't what's causing this?

https://github.com/facebook/react-native/blob/master/jest/mockComponent.js#L20

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that鈥檚 probably it but my understanding was the name line in the render function of that file is the thing that should be setting the component鈥檚 display name. Interestingly, that doesn鈥檛 seem to show up in this snapshot test at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this took a bit. This goes back to my original PR, and this is related to what prompted all of this 馃槵 I tried explaining it but confused myself and deleted it all. I've been doing a bad job explaining it thus far so I think I need some time to put together a cohesive description.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheSavior is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@TheSavior
Copy link
Member

I'm gonna land this as is, we can continue to iterate and improve

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @bcarroll22 in 782dc94.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants