bruderstein / unexpected-react

Plugin for http://unexpected.js.org to enable testing the full React virtual DOM, and also the shallow renderer
http://bruderstein.github.io/unexpected-react
MIT License
187 stars 19 forks source link

Deep rendering of styled-components yields RenderedReactElementData, not RenderedReactElement #54

Open gertsonderby opened 5 years ago

gertsonderby commented 5 years ago

Using the "when deeply rendered" assertion on an element created with the styled-components library, v4+, fails in strange ways due to the result being misidentified as the RenderedReactElementData type. If (as is typical) another assertion follows this, no meaningful error is given, the assertion simply fails with no message, identifying a location in unexpected itself as the fault location.

It seems likely that this is due to styled-components v4 using React.forwardRef. This seems to foil the identification of RenderedReactElement types somehow.

gertsonderby commented 5 years ago

I'll see if I can't set up a simple test case and PR it.

gertsonderby commented 5 years ago

A test with a simple forwardRef'ed component worked just fine. It seems to be some other oddity of styled-components' rearing its head. >_<