react-test-renderer doesn't support Suspense and lazy nodes

Created on 9 Nov 2018  路  6Comments  路  Source: facebook/react

Hello. How can I test components with Suspense/Lazy?
now renderer.create(...)toTree() throws
"toTree() does not yet know how to handle nodes with tag=13"

react 16.6.1
react-test-renderer 16.6.1

Bug

Most helpful comment

Just ran into this as well. Assuming this still isn't supported? The promise never resolves and the suspense state always renders the fallback.

All 6 comments

Getting something similar with Enzyme.
Enzyme Internal Error: unknown node with tag 13

Hi @gaearon , sorry for pinging here. In airbnb/enzyme#1975 we are also stuck with that the shallow renderer doesn't support rendering Suspense.
I'm not sure what should the expected result of shallow render Suspense be (Should the fallback / React.lazy mechanism works here? Or we can have some options in ShallowRender to handle this?). But I think there are some use cases that people will want to shallow render Suspense to get the children under it (like wrapper.dive() in enzyme). It'd be great to make it work.

I suspect that until Buzz (or was it Fizz?) is ready, you'll have to do with just rendering the fallback. The current server renderer is synchronous.

Shallow render is different with server renderer I think. I'm just wondering how we can support Suspense in shallow renderer.

Hi, I'm wondering if there is any decision made regarding how Suspense should be treated with the shallow renderer?
We're currently trying to adapt many of our components to be lazily loaded and we're running into troubles with our snapshot testing where the component names in our snapshots always end up as UNDEFINED if they are lazily loaded.

Just ran into this as well. Assuming this still isn't supported? The promise never resolves and the suspense state always renders the fallback.

Was this page helpful?
0 / 5 - 0 ratings