Skip to content

refactor(breaking): rename container to UNSAFE_root; introduce root host element #1298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 13, 2023

Conversation

mdjastrzebski
Copy link
Member

Summary

This PR contains breaking changes behind useBreakingChanges feature flag.

Resolves #1296

  1. Rename container to UNSAFE_root
  2. Display deprecation messages for container (behind useBreakingChanges )
  3. Expose root API that returns root host element.

Test plan

All tests pass.

@mdjastrzebski mdjastrzebski requested review from AugustinLF, pierrezimmermannbam, MattAgn and thymikee and removed request for AugustinLF January 27, 2023 14:33
@thymikee thymikee changed the title refactor: fix container API refactor(breaking): rename container to UNSAFE_root; introduce root host element Jan 27, 2023
@@ -16,6 +16,12 @@ const defaultScreen: RenderResult = {
get container(): ReactTestInstance {
throw new Error(SCREEN_ERROR);
},
get root(): ReactTestInstance {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this type accurate? Isn't there a narrower type for host elements?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately no, though we might think about something like that in the future

@mdjastrzebski mdjastrzebski force-pushed the refactor/container-api branch from 205d266 to f842f8b Compare January 28, 2023 21:46
A reference to the rendered root element.
Returns the rendered root [host element](testing-env#host-and-composite-components).

This API is primarily useful in component tests, as it allows you to access root host view without using `*ByTestId` queries or similar methods.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it could be interesting to give more indications on what we think are good use cases for this api (e.g. asserting an element is not rendered) because I don't think it's very intuitive how to use this

@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Base: 96.07% // Head: 96.09% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (8597706) compared to base (1e8b3ba).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1298      +/-   ##
==========================================
+ Coverage   96.07%   96.09%   +0.02%     
==========================================
  Files          49       49              
  Lines        3308     3333      +25     
  Branches      497      503       +6     
==========================================
+ Hits         3178     3203      +25     
  Misses        130      130              
Impacted Files Coverage Δ
src/render.tsx 100.00% <100.00%> (ø)
src/screen.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mdjastrzebski mdjastrzebski merged commit 47b125c into main Feb 13, 2023
@mdjastrzebski mdjastrzebski deleted the refactor/container-api branch February 13, 2023 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: re-write container API
4 participants