Skip to content

InlineSVG is not _seen_ as a React Component by Enzyme's shallow rendering #21

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

Open
butlersrepos opened this issue Jun 2, 2017 · 2 comments

Comments

@butlersrepos
Copy link

I'm not sure if this is an issue for here or an issue for Enzyme but I've only ever encountered it while using svg-inline-react.

If I am shallow rendering a component to test, such as

import InlineSVG from 'svg-inline-react'
import mapMarker from '../../assets/icons/map-marker.svg'

const LocationDetails = ({ words }) => (
  <div>
    <InlineSVG src={mapMarker}/>
    <div>{words}</div>
  </div>
)

during the test I can output the shallow(<LocationDetails />).debug() and I see the <InlineSVG> with its attributes but doing a shallow(<LocationDetails />).contains(<InlineSVG />) fails. However doing shallow(<LocationDetails />).find('InlineSVG').length returns 1.

:(

References

http://airbnb.io/enzyme/docs/api/shallow.html

@rafalmaciejewski
Copy link
Contributor

Hey, did you try shallow(<LocationDetails />).contains(InlineSVG) ? It works for me this way.

@butlersrepos
Copy link
Author

I did not try that. In the interim (I know it was short) we have swapped out for SVGInline for the classNames support. I feel confident that your suggestion would work though. Thanks for the look 👍

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