Skip to content

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

@butlersrepos

Description

@butlersrepos

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions