unexpected-react icon indicating copy to clipboard operation
unexpected-react copied to clipboard

Deep rendering of styled-components yields RenderedReactElementData, not RenderedReactElement

Open gertsonderby opened this issue 7 years ago • 2 comments

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 avatar Nov 09 '18 14:11 gertsonderby

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

gertsonderby avatar Nov 09 '18 14:11 gertsonderby

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

gertsonderby avatar Nov 09 '18 15:11 gertsonderby