Skip to content

Conversation

@ssidorchik
Copy link
Contributor

  • BREAKING CHANGE?

Description

This pr adds renderWithTheme testing helper.

Detail

Checklist

  • 👌 design updates are Garden Designer approved (add the
    designer as a reviewer)
  • 💅 view component styling is based on a Garden CSS
    component
  • 🌐 Styleguidist demo is up-to-date (yarn start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 💂‍♂️ includes new unit and snapshot tests
  • 📒 any new files are included in the packages src/index.js export
  • 📝 tested in Chrome, Firefox, Safari, Edge, and IE11

@coveralls
Copy link

coveralls commented Oct 2, 2018

Coverage Status

Coverage decreased (-0.1%) to 95.835% when pulling a53e9cc on ssidorchik/testing-render into 7a32b2d on master.

*/

export { default as mountWithTheme } from './utils/mountWithTheme.js';
export { default as renderWithTheme } from './utils/renderWithTheme.js';
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@austingreendev austingreendev left a 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

@austingreendev austingreendev merged commit 9e95c40 into master Oct 4, 2018
@austingreendev austingreendev deleted the ssidorchik/testing-render branch October 4, 2018 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants