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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test components with react-click-outside #19

Closed
nerdymax opened this issue Mar 28, 2017 · 2 comments
Closed

How to test components with react-click-outside #19

nerdymax opened this issue Mar 28, 2017 · 2 comments

Comments

@nerdymax
Copy link

When a component is exported with enhanceWithClickOutside, enzyme can't find the component in it.

For example, the following fails:

test('Renders the root div', () => {
  const component = shallow(<MyComponent />);
  expect(component).toContain('div#root-div');
});

MyComponent.js

function MyComponent() {
  // ...
  return (
    <div id="root-div">
      {/* ... */}
    </div>
  );
}
export default enhanceWithClickOutside(MyComponent)

What is the workaround?

@kentor
Copy link
Owner

kentor commented Mar 28, 2017

This is a general issue with higher order components. Better to ask at the enzyme project.

Resources:
enzymejs/enzyme#539
maybe use dive?
https://github.com/airbnb/enzyme/blob/e7226255bded93e285e36b50e16b59c8dc2458f9/docs/api/ShallowWrapper/dive.md

@kentor kentor closed this as completed Mar 28, 2017
@hatched
Copy link

hatched commented Sep 5, 2017

@nerdymax We don't use enzyme but you may find PR #25 and Issue #20 helpful for the approach we've taken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants