Container API is broken #1289
Replies: 2 comments 4 replies
-
|
What I lack to fully understand the issue here is how this API is used by users, both RTL and RNTL users. I don't use it personally and I don't see use cases for it, have you any ideas on this? If we feel like it serves no purpose another option would be to remove this API, it would be a change from RTL's API but maybe it's better than having it but with a different behavior from RTL's behavior. Otherwise I think I like the second option most, I'd guess it shouldn't have an important impact on user tests and I don't really like the idea of adding an additional |
Beta Was this translation helpful? Give feedback.
-
|
Based on this discussion, I've prepared a concrete proposal for how to fix issues with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Our
containerAPI, tries to mimic RTLs API of the same name, but does actually something else.One user of Jest Native posted following piece of test:
The main problem with
containerAPI is that it returns root of Test Renderer'sReactTestInstancetree: compositeTestelement, while the user is expecting behavior as if the returned element was root host element. All our queries are (soon) returning only host elements, but this one exposes a composite one.Additionally, in RTL,
containeris a DOM element where test render results are attached, i.e. they are the DOM parent of root element, where in our case the is no concept of parent of not rendered output. The only common thing here is that both ours and RTL's queries are bound to container element.That leaves us with a number of options:
UNSAFE_container- breaking)containerreference root host element (breaking change), perhaps under different name likeroot(non-breaking).containerreference an hostViewthat would wrap users JSX elements. This will be most true to life with RTL, buttoJSON/debugwill now print thisViewby default, breaking all snapshot tests by wrapping them inView. This could be mitigated by makingtoJSON()return only children of thatView.Wdyt @thymikee @AugustinLF @pierrezimmermannbam @MattAgn?
Beta Was this translation helpful? Give feedback.
All reactions