-
Notifications
You must be signed in to change notification settings - Fork 97
feat(testing): add renderWithTheme #171
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
Conversation
| */ | ||
|
|
||
| export { default as mountWithTheme } from './utils/mountWithTheme.js'; | ||
| export { default as renderWithTheme } from './utils/renderWithTheme.js'; |
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.
Is this any different to the above mountWithTheme?
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.
I'm a little lost as well. The only difference I can see is that mountWithTheme is passing the childContext types through the context with { context, childContextTypes: StyledThemeProvider.childContextTypes },
Without that you are probably seeing some Styled-Components console.warns in the console?
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.
@ryanseddon the only difference from the mountWithTheme is that it calls render instead of mount for the passed component. And this is the main purpose of this helper.
@Austin94 good catch! Added childContextTypes to the options.
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.
What use-case would this have for testing? The react-testing packages are mostly around utilities for enzyme & jest testing.
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.
This is exactly for snapshots testing with enzyme. Useful when a component composites smaller none exportable components and mounting to DOM is not needed. shallow doesn't render subcomponents and render is doing this down to html elements.
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.
Thanks for the clarification @ssidorchik. Is this change intended to clean up some of our tests or are you depending on this in your own codebase for testing?
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.
Already using the enzyme's render on a separate project. And would like to add the theme support.
austingreendev
left a comment
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.
From our offline talk, LGTM! TIL about static markup rendering
Description
This pr adds
renderWithThemetesting helper.Detail
Checklist
designer as a reviewer)
component
yarn start)src/index.jsexport