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

find() with class selector is returning composite components with className prop #1237

Closed
ferdaber opened this issue Oct 7, 2017 · 2 comments

Comments

@ferdaber
Copy link

ferdaber commented Oct 7, 2017

Our codebase has instances of common components that you can assign className to that is passed to their root components, like:

const Foo = ({ className }) => <div className={className}>Hello</div>
const wrapper = mount(<div><Foo/></div>)

expect(wrapper.find('.foo').length).toBe(1) //actually returns 2

Is this expected behavior? Since real CSS selectors are being used I figured that className should really only apply to native DOM elements.

@aweary
Copy link
Collaborator

aweary commented Oct 7, 2017

This is expected with Enzyme 3, you can use hostNodes to filter out composite components or use a more specific query like div.foo. See #1179

@aweary aweary closed this as completed Oct 7, 2017
@ferdaber
Copy link
Author

ferdaber commented Oct 7, 2017

great, thanks!

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

2 participants