Let's say that I have a component <BaseImg/> and I want to create another component <TripleImg/> that extends <BaseImg/>.
If I do shallow(<TripleImg/>).type() it will be BaseImg.
Why is that? Is this intended?
By extend, do you mean you are doing this?
class BaseImg extends React.Component { /* ... */ }
class TripleImg extends BaseImg { /* ... */ }
Yes
I don't think this is an issue with Enzyme as we read the type off of the component. I can't find any links right now, but I remember reading about how you shouldn't make components extend from other components...
This thread might help you get your prototype setup correctly: https://github.com/facebook/react/issues/4878
I'm going to close the ticket for now as it doesn't seem like an issue with Enzyme. Feel free to keep the conversation going for support. If it proves to be an issue with Enzyme we can re-open and address it.
I see. Thank you for the clarification. I'll keep looking into it and will write my findings here (if any).
@raduanastases idiomatic React does not ever use inheritance to extend components; you should seriously consider not doing that, and using composition instead.
@ljharb I know, I'll bring it up in my team and maybe we will move to composition. Thanks for the info.