-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Jest snapshot testing example #683
Conversation
Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! 😄 |
CLA is valid! |
Docs is ready and I'll add it after the pull request is merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zouxuoz this is great, thanks so much for adding this example!
I added some minor comments about code formatting, if you have a chance to resolve them that'd be great.
<AppMain/> | ||
<AppFooter/> | ||
</div> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make sure the files end with a newline so that Git can track future changes better.
<FormattedMessage {...messages.copyright} /> | ||
</div> | ||
</footer> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add EOF newline.
import { FormattedMessage, defineMessages } from 'react-intl'; | ||
|
||
const messages = defineMessages({ | ||
copyright: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a mix of 2 and 4 space indentation. If you don't mind can you make it consistent throughout the example?
const { counter } = this.state; | ||
|
||
return ( | ||
<main className="app-main" onClick={this.onClick}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off here.
} | ||
} | ||
|
||
export default AppMain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add EOF newline.
let tree = component.toJSON(); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add EOF newline.
let tree = component.toJSON(); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add EOF newline.
tree = component.toJSON(); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add EOF newline.
ReactDOM.render( | ||
<RootContainer/>, | ||
document.getElementById('root') | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add EOF newline.
); | ||
}; | ||
|
||
export default createComponentWithIntl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add EOF newline.
@ericf sorry for mistakes. I'm resolve it and send pull request with updated eslint for check this mistakes. |
@zouxuoz no worries about the mistakes. I appreciate that you took the time to update the eslint config 😄 Thanks so much for creating this example app and writing up the docs on Jest testing. This will end up serving as my guide when I eventually get around to rewriting React Intl's own tests using Jest. |
I'm added example to show how use Jest snapshot testing for applications with React Intl. (resolve #681)